peasant: use lookup table for HPOSN

not sure if it's that noticable
This commit is contained in:
Vince Weaver 2021-08-12 20:36:32 -04:00
parent 253590a26d
commit 17a1d69f7a
9 changed files with 173 additions and 69 deletions

View File

@ -108,6 +108,7 @@ forever:
.include "draw_box.s"
.include "hgr_rectangle.s"
.include "hgr_input.s"
.include "hgr_tables.s"
.include "graphics_end/end_graphics.inc"

View File

@ -27,7 +27,13 @@ hgr_1x5_sprite_yloop:
ldy #0
; calc GBASL/GBASH
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
; jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
tax
lda hposn_low,X
sta GBASL
lda hposn_high,X
sta GBASH
pla
tax

View File

@ -22,11 +22,18 @@ hgr_1x8_sprite_yloop:
clc
adc CURSOR_Y
ldx #0
ldy #0
; ldx #0
; ldy #0
; calc GBASL/GBASH
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
; jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
tax
lda hposn_low,X
sta GBASL
lda hposn_high,X
sta GBASH
pla
tax

View File

@ -38,7 +38,13 @@ hgr_7x30_sprite_yloop:
ldy #0
; calc GBASL/GBASH
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
; jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
tax
lda hposn_low,X
sta GBASL
lda hposn_high,X
sta GBASH
pla
tax
@ -78,7 +84,13 @@ save_yloop:
ldy #0
; calc GBASL/GBASH
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
; jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
tax
lda hposn_low,X
sta GBASL
lda hposn_high,X
sta GBASH
pla
tax
@ -112,7 +124,13 @@ restore_yloop:
ldy #0
; calc GBASL/GBASH
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
; jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
tax
lda hposn_low,X
sta GBASL
lda hposn_high,X
sta GBASH
pla
tax

View File

@ -6,10 +6,6 @@ COLOR_MODE = TEMP0
OTHER_MASK = TEMP1
XRUN = TEMP2
div7_table = $B000
mod7_table = $B100
; FAST
;=================================
; Simple Rectangle
@ -80,10 +76,16 @@ done_colors:
; get ROW into (GBASL)
ldx VGI_RX1 ; X1 into X
lda VGI_RY1 ; Y1 into A
ldy #0 ; always 0
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
; ldx VGI_RX1 ; X1 into X
; lda VGI_RY1 ; Y1 into A
; ldy #0 ; always 0
; jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
; urgh we depend on HGR_BITS being properly set
jsr fast_hposn
; Y is already the RX1/7
@ -250,57 +252,4 @@ swap_done:
;=====================
; make /7 %7 tables
;=====================
hgr_make_tables:
ldy #0
lda #0
ldx #0
div7_loop:
sta div7_table,Y
inx
cpx #7
bne div7_not7
clc
adc #1
ldx #0
div7_not7:
iny
bne div7_loop
ldy #0
lda #0
mod7_loop:
sta mod7_table,Y
clc
adc #1
cmp #7
bne mod7_not7
lda #0
mod7_not7:
iny
bne mod7_loop
rts
left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
right_masks:
.byte $81,$83,$87, $8F,$9F,$BF,$FF

108
games/peasant/hgr_tables.s Normal file
View File

@ -0,0 +1,108 @@
div7_table = $b800
mod7_table = $b900
hposn_high = $ba00
hposn_low = $bb00
;=====================
; make /7 %7 tables
;=====================
hgr_make_tables:
ldy #0
lda #0
ldx #0
div7_loop:
sta div7_table,Y
inx
cpx #7
bne div7_not7
clc
adc #1
ldx #0
div7_not7:
iny
bne div7_loop
ldy #0
lda #0
mod7_loop:
sta mod7_table,Y
clc
adc #1
cmp #7
bne mod7_not7
lda #0
mod7_not7:
iny
bne mod7_loop
; Hposn table
lda #0
hposn_loop:
ldy #0
ldx #0
pha
jsr HPOSN ; (Y,X),(A)
pla
tax
lda GBASL
sta hposn_low,X
lda GBASH
sta hposn_high,X
inx
txa
cmp #192
bne hposn_loop
rts
left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
right_masks:
.byte $81,$83,$87, $8F,$9F,$BF,$FF
fast_hposn:
lda VGI_RY1
tax
lda hposn_low,X
sta GBASL
lda hposn_high,X
sta GBASH
lda VGI_RX1
tax
ldy div7_table,X
tya
lsr
lda HGR_COLOR ; if on odd byte rotate bits
sta HGR_BITS
bcc done_hposn
jsr COLOR_SHIFT
done_hposn:
rts

View File

@ -63,7 +63,7 @@ check_lake_e_action1:
jmp done_lake_e_action
check_lake_e_action2:
cmp #27
cmp #28
bne done_lake_e_action
jsr hgr_restore
lda #PEASANT_DIR_UP

View File

@ -74,6 +74,8 @@ peasant_quest:
.include "hgr_1x5_sprite.s"
.include "hgr_save_restore.s"
.include "hgr_input.s"
.include "hgr_tables.s"
.include "wait_a_bit.s"
.include "graphics/graphics.inc"

View File

@ -77,8 +77,20 @@ mockingboard_found:
mockingboard_notfound:
;=========================
; set up hgr lookup tables
;=========================
jsr hgr_make_tables
;=======================
; start music
;=======================
cli
;************************
; Title
;************************
@ -119,5 +131,6 @@ do_title:
.include "directions.s"
.include "hgr_font.s"
.include "hgr_tables.s"
.include "graphics_title/title_graphics.inc"