.pc =$0801 "Basic Starter" :BasicUpstart($0820) .pc=$0810 "Constants" multicol: .byte $00 bgcol: .byte $06 sprcol: .byte $0e sprmcol1: .byte $00 sprmcol2: .byte $00 .pc = $0820 "Code" sei lda multicol sta $d01c lda bgcol sta $d020 sta $d021 lda sprmcol1 sta $d025 lda sprmcol2 sta $d026 lda sprcol ldx #$07 !loop: sta $d027,x dex bpl !loop- ldx #$00 lda #$20 !loop: sta $0400,x sta $0500,x sta $0600,x sta $0700,x inx bne !loop- lda #$ff sta $d015 lda #$80 sta $d010 ldx #$07 ldy #$00 lda #$18+44 !loop: sta $d000,y clc adc #29 iny iny dex bpl !loop- jsr generatefont lda #$35 sta $01 mainloop: lda #$2f sta ycoord lda #$80 sta spridx yloop: lda ycoord !wait: cmp $d012 bne !wait- clc adc #4 ldx #$07 ldy #$00 !loop: sta $d001,y iny iny dex bpl !loop- ldx #$00 ldy spridx !loop: tya sta $07f8,x iny inx cpx #8 bne !loop- clc lda spridx adc #8 sta spridx lda ycoord adc #25 sta ycoord cmp #$2f+8*25 bne yloop jmp mainloop ycoord: .byte 0 spridx: .byte 0 .pc=$0900 "Font generation code" generatefont: rts
Correct, no specific state of anything is to be assumed! I'll make an alternate, secret viewer, that loads somewhere completely else in memory and abuses stack and registers etc. before calling the $0900 code, and if your sprites don't look the same way then, it will be disqualified! :)
My only question then is how do we know what memory is safe to use as working space?
# This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # disp.s # font.s # mem.cfg # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' XAS=ca65 --cpu 6502X XLD=ld65 X Xall: go.prg Xrun: go.prg X open $< X Xgo.prg: disp.o font.o X $(LD) -o $@ -m init.map -C mem.cfg $(AFLAGS) $^ X X%.o: %.s X $(AS) $(AFLAGS) $< Xclean: X rm -f *.o *.prg *.map END-of-Makefile echo x - disp.s sed 's/^X//' >disp.s << 'END-of-disp.s' X .import generatefont X .export fontbase X Xfontbase=$2000 X X .segment "STARTUP" X .word basicstub ; load address Xbasicstub: X .byte $0b,$08,$0a,$00,$9e,$32,$30,$38,$30,0,0,0 ; sys 2080 X .res 3 Xmulticol: X .byte $00 Xbgcol: X .byte $06 Xsprcol: X .byte $0e Xsprmcol1: X .byte $00 Xsprmcol2: X .byte $00 X .res 11 X X sei X lda multicol X sta $d01c X lda bgcol X sta $d020 X sta $d021 X lda sprmcol1 X sta $d025 X lda sprmcol2 X sta $d026 X lda sprcol X ldx #$07 X: X sta $d027,x X dex X bpl :- X ldx #$00 X lda #$20 X: X sta $0400,x X sta $0500,x X sta $0600,x X sta $0700,x X inx X bne :- X lda #$ff X sta $d015 X lda #$80 X sta $d010 X ldx #$07 X ldy #$00 X lda #$18+44 X: X sta $d000,y X clc X adc #29 X iny X iny X dex X bpl :- X jsr generatefont X lda #$35 X sta $01 Xmainloop: X lda #$2f X sta ycoord X lda #$80 X sta spridx Xyloop: X lda ycoord X: X cmp $d012 X bne :- X clc X adc #4 X ldx #$07 X ldy #$00 X: X sta $d001,y X iny X iny X dex X bpl :- X ldx #$00 X ldy spridx X: X tya X sta $07f8,x X iny X inx X cpx #8 X bne :- X clc X lda spridx X adc #8 X sta spridx X lda ycoord X adc #25 X sta ycoord X cmp #$2f+8*25 X bne yloop X jmp mainloop X Xycoord: X .byte 0 Xspridx: X .byte 0 X END-of-disp.s echo x - font.s sed 's/^X//' >font.s << 'END-of-font.s' X .export generatefont X .import fontbase X .segment "ZEROPAGE" Xzp: X .res 2 X X .segment "FONT" Xgeneratefont: X lda#<fontbase X sta zp X lda#>fontbase X sta zp+1 X rts X X END-of-font.s echo x - mem.cfg sed 's/^X//' >mem.cfg << 'END-of-mem.cfg' X XMEMORY { X ZP: start = $02, size = $fe, type = rw, define = yes; X RAM: start = $07FF, size = $0201, define = yes, file = %O; X} XSEGMENTS { X STARTUP: load = RAM, type = ro; X FONT: load = RAM, type = ro, align=256; X ZEROPAGE: load = ZP, type = zp; X} END-of-mem.cfg exit