From b61b08fa6053cdc416a6cca33078aada8bebb738 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 5 Feb 2013 16:07:02 -0500 Subject: [PATCH] snes: validate all rep/sep setting register size URGH I hate how they did this, and it would be nicer if it had a better mnemonic. I guess I could redefine myself. anyway all of them should be proper now --- tb1_snes/checksum.inc | 4 +-- tb1_snes/level_1.s | 59 +++++++++++++++++++++++++------------------ tb1_snes/opening.s | 2 +- tb1_snes/snes_init.s | 10 +++++--- tb1_snes/svmwgraph.s | 4 +-- 5 files changed, 45 insertions(+), 34 deletions(-) diff --git a/tb1_snes/checksum.inc b/tb1_snes/checksum.inc index a96e301..3460c8e 100644 --- a/tb1_snes/checksum.inc +++ b/tb1_snes/checksum.inc @@ -1,2 +1,2 @@ - .word $186d ; Complement of checksum - .word $e792 ; Unsigned 16-bit sum of ROM + .word $9ae ; Complement of checksum + .word $f651 ; Unsigned 16-bit sum of ROM diff --git a/tb1_snes/level_1.s b/tb1_snes/level_1.s index fefa83a..d0bb3af 100644 --- a/tb1_snes/level_1.s +++ b/tb1_snes/level_1.s @@ -499,6 +499,8 @@ new_level: ;+ MAIN LEVEL1 LOOP + ;+ + ;\========================/ +.a8 +.i16 level1_loop: @@ -790,11 +792,35 @@ setup_enemy_defaults: store_enemy_kind: + ; Xxxxxxxxx yyyyyyy cccccccc vhoo pppN + clc adc #$60 ; Use pal2 enemies for now + + pha ; store type for later + + ; Y = $20+enemies + + ; want to store to $200 + (Y*4) + + rep #$20 ; set A to 16-bit +.a16 + + tya ; copy Y to A + asl + asl ; multiply by 4 + clc + adc #$200 ; add in $200 + tax + + + sep #$20 ; set A back to 8-bit +.a8 + pla ; restore A + + sta $282 ; $200 + $20*4 + 2 - ; Xxxxxxxxx yyyyyyy cccccccc vhoo pppN lda #$24 sta $283 ; noflip, pal2, priority=2 @@ -2067,32 +2093,13 @@ level_print_loop: lda star_scroll_h sta $2110 - rep #$20 ; A/mem=16 bit + rep #$20 ; A/mem=16 bit .a16 dec star_scroll - sep #$20 ; A/mem=8 bit + sep #$20 ; A/mem=8 bit .a8 - ; handle keypress -; lda joypad1 -check_left: -; bit #$02 -; beq check_right - -; dec shipx - -; bpl check_right -; stz shipx - -check_right: -; bit #$01 -; beq no_keypress - -; inc shipx - -;no_keypress: - ;======================== ; update OAM ;======================== @@ -2107,7 +2114,7 @@ check_right: done_game: - ldx #30 +; ldx #30 ; jsr wait_X_100msec ; pause for 3 seconds ; bit KEYRESET ; clear keyboard @@ -2334,6 +2341,7 @@ level1_vblank: php ; save status register rep #$30 ; Set A/mem=16 bits, X/Y=16 bits (to push all 16 bits) .a16 ; tell assembler the A is 16-bits +.i16 phb ; save b pha ; save A phx ; save X @@ -2348,7 +2356,7 @@ joypad_read: and #$01 ; if joy is not ready bne joypad_read ; wait - rep #$20 + rep #$20 ; A 16-bit .a16 ldx joypad1_raw ; load previous raw value @@ -2367,7 +2375,7 @@ joypad_read: and joypad1_raw ; find buttons being held sta joypad1_held ; store held down buttons - sep #$20 + sep #$20 ; A=8bit .a8 @@ -2385,6 +2393,7 @@ done_vblank: rep #$30 ; A/Mem=16 bits, X/Y=16 bits .a16 +.i16 pld ; restore saved vaules from stack ply plx diff --git a/tb1_snes/opening.s b/tb1_snes/opening.s index d12bd3d..d0f37f5 100644 --- a/tb1_snes/opening.s +++ b/tb1_snes/opening.s @@ -100,7 +100,7 @@ display_opening: ; BG2 tile data starts at VRAM e000 - rep #$20 ; mem/A = 8 bit + rep #$20 ; mem/A = 16 bit .a16 diff --git a/tb1_snes/snes_init.s b/tb1_snes/snes_init.s index 8e725cb..490d8f7 100644 --- a/tb1_snes/snes_init.s +++ b/tb1_snes/snes_init.s @@ -148,8 +148,9 @@ ClearVRAM: phx php - rep #$30 ; mem/A = 8 bit, X/Y = 16 bit - sep #$20 + rep #$10 ; X/Y = 16 bit +.i16 + sep #$20 ; A = 8 bit .a8 lda #$80 sta $2115 ; Set VRAM port to word access @@ -175,8 +176,9 @@ ClearVRAM: ClearPalette: phx php - rep #$30 ; mem/A = 8 bit, X/Y = 16 bit - sep #$20 + rep #$10 ; X/Y = 16 bit +.i16 + sep #$20 ; A = 8 bit .a8 stz $2121 ldx #$0100 diff --git a/tb1_snes/svmwgraph.s b/tb1_snes/svmwgraph.s index a18a3fa..a1c04c5 100644 --- a/tb1_snes/svmwgraph.s +++ b/tb1_snes/svmwgraph.s @@ -285,7 +285,7 @@ is_sprite_active: php ; save status - rep #$30 + rep #$30 ; A=16bit X/Y=16bit .i16 .a16 @@ -312,7 +312,7 @@ is_sprite_active: and $0400,Y ; sprite on screen when bit is 0 - rep #$20 + rep #$20 ; A=16 bit .a16 beq sprite_is_active