diff options
Diffstat (limited to 'src/jetpac.s')
| -rw-r--r-- | src/jetpac.s | 113 |
1 files changed, 58 insertions, 55 deletions
diff --git a/src/jetpac.s b/src/jetpac.s index 2f273a3..8acbb4e 100644 --- a/src/jetpac.s +++ b/src/jetpac.s @@ -5,28 +5,74 @@ .segment "CODE" +;; NOTE: automatically generated by the build system. +.include "../config/generated.s" + .include "../include/apu.s" .include "../include/oam.s" .include "../include/ppu.s" +.include "../include/asm.s" +.include "../include/joypad.s" .include "../include/globals.s" + +.include "assets.s" +.include "driver.s" +.include "title.s" .include "vectors.s" .proc main - jsr init_palettes - jsr init_nametables + ;; Disable the PPU. + lda #0 + sta PPU::MASK + + ;; Initialize the assets for the game. + jsr Assets::init + + ;; We shadow the PPU control register in memory. Depending on the `make` + ;; target we might need to switch directly to the main game. Otherwise we go + ;; into the title as expected. + .ifdef PARTIAL + jsr Driver::switch + + lda PPU::zp_control + sta PPU::CONTROL + .else + jsr Title::init + + lda #%10001000 + sta PPU::zp_control + sta PPU::CONTROL + .endif -;;; TODO cli - lda #%10110000 - sta $2000 + + ;; Enable back the PPU lda #%00011110 - sta $2001 + sta PPU::MASK @main_game_loop: - ;;; - ;; TODO - ;;; + READ_JOYPAD1 + + lda Globals::zp_flags + and #%00000011 + beq @title_screen + cmp #1 + beq @game_screen + jmp @over +@title_screen: + jsr Title::update + beq @set_flags + + ;; Start was pressed by the player, switch to the main game. + jsr Driver::switch + jmp @set_flags + +@game_screen: + jsr Driver::update + ;; NOTE: fallthrough + +@set_flags: lda #%10000000 ora Globals::zp_flags sta Globals::zp_flags @@ -36,51 +82,8 @@ ;; Rendering is done, we can perform another iteration of the loop! jmp @main_game_loop -.endproc -;; Copies all the palettes for our game into the proper PPU address. -.proc init_palettes - lda #$3F - sta PPU::ADDRESS - lda #$00 - sta PPU::ADDRESS - - ldx #0 -@load_palettes_loop: - lda palettes, x - sta PPU::DATA - inx - cpx #$20 - bne @load_palettes_loop - rts -palettes: - ;; Background - ;; 0: score - .byte $0F, $30, $2C, $28 - ;; 1: floating platforms - .byte $0F, $2C, $30, $2A - ;; 2: ground - .byte $0F, $28, $14, $28 - ;; 3: ship - .byte $0F, $16, $30, $00 - - ;; TODO: fuel tank needs color $24 - ;; Foreground - ;; 0: player & ship - .byte $0F, $16, $10, $30 - ;; 1: enemy 1 & bonuses - .byte $0F, $16, $2C, $2A - ;; 2: enemy 2, fuel & bonuses - .byte $0F, $16, $14, $28 - ;; 3: SUSE easter egg - .byte $0F, $16, $00, $2B +@over: + ;; TODO: allow to start over, reset flags, control register, etc. + jmp @over .endproc - -.proc init_nametables - ;; TODO - rts -.endproc - - -.segment "CHARS" - .incbin "../assets/jetpac.chr" |
