From dfb441049742e3ba50e19089d5f2a65fb1547220 Mon Sep 17 00:00:00 2001 From: Safiire Date: Thu, 5 Mar 2015 17:21:51 -0800 Subject: [PATCH] Updated the demo, realized anonymous scopes don't work right :( --- demo.asm | 41 ++++++++++++++++++++--------------- lib/directives/enter_scope.rb | 14 +++++++++--- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/demo.asm b/demo.asm index e08b9b3..a86ea3b 100644 --- a/demo.asm +++ b/demo.asm @@ -25,10 +25,10 @@ sprite: .dw irq -.org $C000 ;;;; ; Here is our code entry point, which we'll call main. -main: +.org $C000 +.scope main ; Disable interrupts and decimal flag sei cld @@ -74,40 +74,43 @@ main: cli forever: jmp forever +. ;;;; ; Set basic PPU registers. Load background from $0000, ; sprites from $1000, and the name table from $2000. -init_ppu: +.scope init_ppu lda #$88 sta $2000 lda #$1E sta $2001 rts +. ;;;; ; Initialize all the sprites, palettes, nametables, and scrolling -init_graphics: +.scope init_graphics jsr init_sprites jsr load_palette jsr load_name_tables jsr init_scrolling rts +. ;;;; ; Initialize the controller input, keeping track of the A button -init_input: +.scope init_input lda #$00 sta $01 ; $01 = A button rts +. ;;;; ; Initialize the APU to known values -init_sound: - ; initialize sound hardware +.scope init_sound lda #$01 sta $4015 lda #$00 @@ -115,13 +118,14 @@ init_sound: lda #$40 sta $4017 rts +. ;;;; ; Clear page #2, which we'll use to hold sprite data ; This subroutine clearly shows why I need to have symbols ; to refer to bits of RAM in the zero page like dx, etc. -init_sprites: +.scope init_sprites lda #$00 ldx #$00 sprite_clear1: @@ -140,26 +144,28 @@ init_sprites: lda #$01 sta $00 ; dx = $00 rts +. ;;;; ; Load palette into $3F00 -load_palette: +.scope load_palette lda #$3F ldx #$00 sta $2006 stx $2006 - loady_loop: + loop: lda palette, X sta $2007 inx cpx #$20 - bne loady_loop + bne loop rts +. ;;;; ; Put the ASCII values from bg into the first name table, at $2400 ; The tile values are conveniently mapped to their ASCII values -load_name_tables: +.scope load_name_tables ldy #$00 ldx #$04 lda #