From ea64131cdaf10d8908c83e2d7d7859a3cffa9cfb Mon Sep 17 00:00:00 2001 From: droniu Date: Sun, 23 May 2021 10:57:11 +0200 Subject: [PATCH] second nametable, game start on enter --- simple/grid.bin | Bin 1024 -> 1024 bytes simple/main.s | 100 ++++++++++++++++++++++++++++++------------- simple/main_menu.bin | Bin 0 -> 1024 bytes simple/smile.bin | Bin 1024 -> 0 bytes simple/start.bin | Bin 1024 -> 0 bytes 5 files changed, 71 insertions(+), 29 deletions(-) create mode 100644 simple/main_menu.bin delete mode 100644 simple/smile.bin delete mode 100644 simple/start.bin diff --git a/simple/grid.bin b/simple/grid.bin index 999a7378b4b21cd18ff3cad947b731b77d30b13c..86c61409148180237a78202ec4a0945f0d00812a 100644 GIT binary patch literal 1024 zcmZQzpcLq9D_E!)G8CbhV`QvgXlxV@5`)SYqsY^QlK?RlN?}?tc;yqYfT84mh+A=o YFBb1X6(jo+w|l8vpBGData - sta background+1 + lda #MenuData + sta menuBg+1 ; setup address in PPU for nametable data bit $2002 @@ -101,37 +106,63 @@ ldx #$00 ldy #$00 - LoadBackground: - lda (background), Y + LoadMenuLoop: + lda (menuBg), Y sta $2007 iny ; 960 px is 03 C0 in hex cpx #$03 bne :+ cpy #$C0 - beq DoneLoadingBG + beq MenuDone : cpy #$00 - bne LoadBackground + bne LoadMenuLoop inx - inc background+1 - jmp LoadBackground + inc menuBg+1 + jmp LoadMenuLoop - DoneLoadingBG: + MenuDone: ldx #$00 - - LoadSprites: - lda SpriteData, X - sta $0200, X + LoadGame: + ; initialize world variable to point to world data + lda #GridData + sta gameBg+1 + + ; setup address in PPU for nametable data + bit $2002 + lda #$28 + sta $2006 + lda #$00 + sta $2006 + + ldx #$00 + ldy #$00 + + LoadGameLoop: + lda (gameBg), Y + sta $2007 + iny + ; 960 px is 03 C0 in hex + cpx #$03 + bne :+ + cpy #$C0 + beq FinishLoadingGame + : + cpy #$00 + bne LoadGameLoop inx - cpx #$20 - bne LoadSprites - + inc gameBg+1 + jmp LoadGameLoop + + FinishLoadingGame: ; enable interrupts cli - lda #%10010000 ; enable NMI, use second set of sprites + lda #%10000000 ; enable NMI sta $2000 ; enable drawing in leftmost 8px of screen and in general lda #%00011110 @@ -140,7 +171,7 @@ Forever: - jmp Forever ; prevents going to NMI after pushing reset + jmp Forever ; game loop ; ; ; ; ; ; ; ; ; ; ; ; @@ -183,8 +214,13 @@ CheckUp: lda #%00010000 and pressing - beq CheckA + beq CheckStart jsr MoveUp + CheckStart: + lda #%00001000 + and pressing + beq CheckA + jsr StartGame CheckA: lda #%00000001 and pressing @@ -213,9 +249,15 @@ adc #$0002 sta $0200 rts - - - + StartGame: + lda #$01 + cmp gameLoaded + bne LoadGrid + rts ; back if game already loaded + LoadGrid: + lda #%10000010 ; enable NMI + sta $2000 + rts ; ; ; ; ; ; ; ; ; ; ; ; @@ -228,8 +270,6 @@ sta $4014 jsr CheckController - lda $2002 - sta debug rti ; interrupt return @@ -251,8 +291,10 @@ SpriteData: ; example .byte $BF, $15, $00, $80 - BGData: + GridData: .incbin "grid.bin" + MenuData: + .incbin "main_menu.bin" .segment "VECTORS" ; special address which 6502 needs diff --git a/simple/main_menu.bin b/simple/main_menu.bin new file mode 100644 index 0000000000000000000000000000000000000000..5c8cb6ad04976f79da0ec420615d2b8afd0c8736 GIT binary patch literal 1024 zcmXRe!V8Lv@k$pJ7c<}m$nyF5`3wvo1frn;Sso+@mWN3KX`0C6vLDG_7!%okkh@_R zn>@trKs7K)AdRdaEDtgRpFB{Op!`6(ALKq<_5&Rbay?%6L&Fdj1SsJH6GWnsYRf42@->YLMiSbRn2@ls60XbE`>$Go1Os~Tss{z~lc((%53LXDcxBTXF{A}rxpLl6~b{Fg-?@BulDtU b@VF-P0#JK9$Hh>ZmgsL_j-L8Boj+aw`#}jD diff --git a/simple/start.bin b/simple/start.bin deleted file mode 100644 index ed1b1cf322839d65439708fa5f67e54f63abe33d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 ecmZQz7zNM}2=;K&33dQtKbO%k84ZDv5dr|BnF8