Geometry Dash gained its initial popularity during my middle school years. Witnessing it being ported like this would definitely be intriguing!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuMiddleLines
stx COLUP0
sty COLUP0
inx
iny
SLEEP 20
sta RESP0
SLEEP 10
sta RESP1
sty GRP0
iny ; modify sprite 0 shape
stx GRP1
sta WSYNC
inx
cpx #184
bne MiddleLines
this code that does work.MiddleLines
stx COLUP0
sty COLUP0
dex
iny
SLEEP 20
sta RESP0
SLEEP 10
sta RESP1
sty GRP0
iny ; modify sprite 0 shape
stx GRP1
sta WSYNC
inx
cpx #184
bne MiddleLines
The other sprite just becomes a square! I have no idea why this happens, but it only seems to happen with DEX and DEY
Quote from: JetSetIlly on 31 Jan 2024, 07:54 PMHi Elijah,Hello there,
First of all, well done on getting this far. Looking at your code the first problem I see is that you've placed the "mainplayer" data in the middle of the executable code. This means that the 2600 will try execute the data!
So, in this case, after executing the "ldx #os_h" instruction the program counter will be pointing to the memory location holding the %00000111 byte. I'm not sure what instruction this is without looking it up, but I know it can't be anything good.
A few cycles later the program counter will point to the %00000000 instruction, which I know is a BRK instruction. This causes your program to start all over again from the very beginning.
So, first thing you should do is move the mainplayer data block so that it is "outside" the executable data. A good place will be after the "ORG $F000" directive and before the "reset:" label
Looking at the player code I'm sure there are other problems but move the data block as instructed first and see how you get on from there.
Quote from: alex_79 on 31 Jan 2024, 09:16 PMYou also need to intialize the decimal flag and stack pointer because the internal state of the CPU is undetermined when you power on the console.
e.g. add this at the beginning of your "reset" code:cld ;clear the decimal flag
If you don't, the result of arithmetic operations (ADC, SBC) might not be the expected one, and using subroutines might overwrite your variables or TIA registers.
ldx #$ff
txs ;set the stack pointer to "$ff"
processor 6502
include "vcs.h"
include "macro.h"
SEG
PFCOL equ #$A2
Pfheight equ #192
os_h equ #34
Playerheight equ #10
BACKGROUND equ #$00
COL0 equ #$1E
seg.u vars ; uninitialized segment
org $80
p0_y ds 1
tp0_y ds 1
scanline ds 1
seg main
ORG $F000
reset: ldx #0 ; Clear RAM and all TIA registers
lda #0
clear: sta 0,x ; $0 to $7F (0-127) reserved OS page zero, $80 to $FF (128-255) user zero page ram.
inx
bne clear
lda #%00000001 ; Set D0 to reflect the playfield
sta CTRLPF ; Apply to the CTRLPF register
lda #PFCOL
sta COLUPF ; Set the PF color
lda #COL0
sta COLUP0
sta WSYNC
SLEEP 19
sta RESP0
StartOfFrame:
lda #%00000010
sta VSYNC
sta WSYNC
sta WSYNC
sta WSYNC
; turn off vsync
lda #0
sta VSYNC
ldx #0
lvblank: sta WSYNC
inx
cpx #37
bne lvblank
ldx #0
Drawfield: lda #%00000000 ;2
sta PF0 ;3
sta PF1 ;3
sta PF2 ;3
stx COLUBK ;note, havent loaded background yet, 3
sta WSYNC ;3
inx ;2
cpx #162 ;2?
bne Drawfield ;2
ldx #0 ;2
Drawfield2: lda #%11111100 ;2
sta PF0 ;3
sta PF1 ;3
sta PF2 ;3
lda #BACKGROUND ;load background color,3
sta COLUBK ;3
inx ;2
cpx #30 ;2
bne Drawfield2 ;2
ldx #0 ;2
player1
lda #Playerheight
sec
sbc tp0_y ; Replace "isb tp0_y" with "sbc tp0_y"
bcs draw_player
lda #0
draw_player
tay
lda mainplayer,y
sta WSYNC
sta GRP0
dec scanline
bne player1
sta WSYNC
lda #%00000010
sta VBLANK
ldx #os_h
mainplayer
;just a square
.byte %00000111 ;
.byte %00000111 ;
.byte %00000111 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
.byte %00000000 ;
overscan: sta WSYNC
inx
cpx #30
bne overscan
jmp StartOfFrame
org $FFFA
irqvectors:
.word reset ; NMI
.word reset ; RESET
.word reset ; IRQ