From 5daa045271eb7a126c9e6fef166cec0ff4f7a868 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Mon, 18 Jan 2021 07:55:59 +0100 Subject: [PATCH] Fine-tuning the logic. --- .../cache/fragment-cache-wdc65c02.asm | 1694 ++++++----------- src/main/kc/include/veralib.h | 42 +- src/main/kc/lib/conio-cx16.c | 2 +- src/main/kc/lib/veralib.c | 70 +- src/test/kc/examples/cx16/dword_low_hi.c | 1 + src/test/kc/examples/cx16/dword_word.c | 13 + src/test/kc/examples/cx16/tilemap.c | 8 +- .../kc/examples/cx16/tilemap_2bpp_8_x_8.c | 4 +- .../kc/examples/cx16/tilemap_4bpp_16_x_16.c | 4 +- .../kc/examples/cx16/tilemap_4bpp_8_x_8.c | 6 +- .../kc/examples/cx16/tilemap_8bpp_8_x_8.c | 4 +- 11 files changed, 690 insertions(+), 1158 deletions(-) create mode 100644 src/test/kc/examples/cx16/dword_word.c diff --git a/src/main/fragment/cache/fragment-cache-wdc65c02.asm b/src/main/fragment/cache/fragment-cache-wdc65c02.asm index b33f864d7..cdf1404df 100644 --- a/src/main/fragment/cache/fragment-cache-wdc65c02.asm +++ b/src/main/fragment/cache/fragment-cache-wdc65c02.asm @@ -10,37 +10,6 @@ sta {z1}+1 //FRAGMENT vbuz1=_deref_pbuc1 lda {c1} sta {z1} -//FRAGMENT vduz1=vwuc1 -NO_SYNTHESIS -//FRAGMENT vduz1=vduc1 -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 -lda #<{c1}>>$10 -sta {z1}+2 -lda #>{c1}>>$10 -sta {z1}+3 -//FRAGMENT vduz1=vbuc1 -lda #{c1} -sta {z1} -lda #0 -sta {z1}+1 -sta {z1}+2 -sta {z1}+3 -//FRAGMENT vwuz1=vbuc1 -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 -//FRAGMENT _deref_pwuc1=vwuc2 -lda #<{c2} -sta {c1} -lda #>{c2} -sta {c1}+1 -//FRAGMENT _deref_pbuc1=vbuc2 -lda #{c2} -sta {c1} //FRAGMENT vbuz1_lt_vbuz2_then_la1 lda {z1} cmp {z2} @@ -52,178 +21,33 @@ stx {z1} //FRAGMENT vbuz1=vbuz2 lda {z2} sta {z1} -//FRAGMENT pvoz1=pvoc1 -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 -//FRAGMENT 0_eq_vbuz1_then_la1 -lda {z1} -cmp #0 -beq {la1} -//FRAGMENT pbuc1_derefidx_vbuz1=pbuc1_derefidx_vbuz1_plus_1 -ldy {z1} -lda {c1},y -inc -sta {c1},y -//FRAGMENT vbuz1=_inc_vbuz1 -inc {z1} -//FRAGMENT vbuz1_neq_0_then_la1 -lda {z1} -cmp #0 -bne {la1} -//FRAGMENT pvoz1=pvoz2 -lda {z2} -sta {z1} -lda {z2}+1 -sta {z1}+1 -//FRAGMENT vwuz1=vwuz1_plus_vwuc1 -clc -lda {z1} -adc #<{c1} -sta {z1} -lda {z1}+1 -adc #>{c1} -sta {z1}+1 -//FRAGMENT vbuz1_neq_vbuc1_then_la1 -lda #{c1} -cmp {z1} -bne {la1} -//FRAGMENT vwuz1=vwuz2 -lda {z2} -sta {z1} -lda {z2}+1 -sta {z1}+1 -//FRAGMENT vbuz1=vbuz1_plus_2 -lda {z1} -clc -adc #2 -sta {z1} -//FRAGMENT vwuz1=_inc_vwuz2 -clc -lda {z2} -adc #1 -sta {z1} -lda {z2}+1 -adc #0 -sta {z1}+1 -//FRAGMENT vwuz1=vwuz2_band_vbuc1 -lda #{c1} -and {z2} -sta {z1} -lda #0 -sta {z1}+1 -//FRAGMENT _deref_pbuc1=_deref_pbuc1_bor__deref_pbuc2 -lda {c1} -ora {c2} -sta {c1} //FRAGMENT pbuz1=pbuc1 lda #<{c1} sta {z1} lda #>{c1} sta {z1}+1 -//FRAGMENT vbuz1_eq_vbuc1_then_la1 -lda #{c1} -cmp {z1} -beq {la1} -//FRAGMENT vwuz1_eq_vbuc1_then_la1 -lda #{c1} -cmp {z1} -bne !+ -lda {z1}+1 -bne !+ -jmp {la1} -!: -//FRAGMENT vwuz1_neq_vwuc1_then_la1 -lda {z1}+1 -cmp #>{c1} -bne {la1} -lda {z1} -cmp #<{c1} -bne {la1} -//FRAGMENT vbuz1=vbuz1_bor_vbuc1 -lda #{c1} -ora {z1} -sta {z1} -//FRAGMENT pbuc1_derefidx_vbuz1=vbuc2 +//FRAGMENT _deref_pbuc1=vbuc2 lda #{c2} -ldy {z1} -sta {c1},y -//FRAGMENT vbuz1=vbuz2_rol_1 -lda {z2} -asl -sta {z1} -//FRAGMENT pwuc1_derefidx_vbuz1=vwuc2 -ldy {z1} +sta {c1} +//FRAGMENT _deref_pwuc1=vwuc2 lda #<{c2} -sta {c1},y +sta {c1} lda #>{c2} -sta {c1}+1,y -//FRAGMENT vbuz1=vbuz2_bor_vbuc1 -lda #{c1} -ora {z2} -sta {z1} -//FRAGMENT vwuz1=_lo_vduz2 -lda {z2} -sta {z1} -lda {z2}+1 -sta {z1}+1 -//FRAGMENT pwuc1_derefidx_vbuz1=vwuz2 -ldy {z1} -lda {z2} -sta {c1},y -lda {z2}+1 -sta {c1}+1,y -//FRAGMENT vwuz1=_hi_vduz2 -lda {z2}+2 -sta {z1} -lda {z2}+3 -sta {z1}+1 -//FRAGMENT pbuc1_derefidx_vbuz1=_byte_vwuz2 -ldy {z1} -lda {z2} -sta {c1},y -//FRAGMENT vbuz1=vbuz2_rol_2 -lda {z2} -asl -asl -sta {z1} -//FRAGMENT pduc1_derefidx_vbuz1=vduz2 -ldx {z1} -lda {z2} -sta {c1},x -lda {z2}+1 -sta {c1}+1,x -lda {z2}+2 -sta {c1}+2,x -lda {z2}+3 -sta {c1}+3,x -//FRAGMENT vduz1=vduz2_ror_1 -lda {z2}+3 -lsr -sta {z1}+3 -lda {z2}+2 -ror -sta {z1}+2 -lda {z2}+1 -ror -sta {z1}+1 -lda {z2} -ror -sta {z1} -//FRAGMENT vbuz1=_hi_vwuz2 -lda {z2}+1 -sta {z1} -//FRAGMENT vbuz1=vbuz2_band_vbuc1 -lda #{c1} -and {z2} -sta {z1} -//FRAGMENT pwuc1_derefidx_vbuz1=vbuc2 -lda #{c2} -ldy {z1} -sta {c1},y +sta {c1}+1 +//FRAGMENT _deref_pwuc1=vbuc2 lda #0 -sta {c1}+1,y +sta {c1}+1 +lda #<{c2} +sta {c1} +//FRAGMENT _deref_pduc1=vduc2 +lda #<{c2} +sta {c1} +lda #>{c2} +sta {c1}+1 +lda #<{c2}>>$10 +sta {c1}+2 +lda #>{c2}>>$10 +sta {c1}+3 //FRAGMENT vbuz1=_deref_pbuc1_ror_7 lda {c1} rol @@ -244,10 +68,15 @@ sta {z1} //FRAGMENT _deref_pbuc1=vbuz1 lda {z1} sta {c1} -//FRAGMENT pbuc1_derefidx_vbuz1=vbuz2 +//FRAGMENT vwuz1=vwuz2 lda {z2} -ldy {z1} -sta {c1},y +sta {z1} +lda {z2}+1 +sta {z1}+1 +//FRAGMENT vbuz1=vbuz2_rol_1 +lda {z2} +asl +sta {z1} //FRAGMENT pbuz1=qbuc1_derefidx_vbuz2 ldy {z2} lda {c1},y @@ -265,6 +94,14 @@ bcs {la1} //FRAGMENT 0_lt_vbuz1_then_la1 lda {z1} bne {la1} +//FRAGMENT pbuc1_derefidx_vbuz1=vbuc2 +lda #{c2} +ldy {z1} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuz1=vbuz2 +lda {z2} +ldy {z1} +sta {c1},y //FRAGMENT vwuz1=_word_vbuz2 lda {z2} sta {z1} @@ -283,60 +120,12 @@ rol {z1}+1 dey bne !- !e: -//FRAGMENT _deref_pbuc1=_deref_pbuc1_band_vbuc2 -lda #{c2} -and {c1} -sta {c1} -//FRAGMENT vbuz1=_lo_pvoz2 +//FRAGMENT pwuc1_derefidx_vbuz1=vwuz2 +ldy {z1} lda {z2} -sta {z1} -//FRAGMENT vbuz1=_hi_pvoz2 +sta {c1},y lda {z2}+1 -sta {z1} -//FRAGMENT _deref_pbuc1=_deref_pbuc1_bor_vbuc2 -lda #{c2} -ora {c1} -sta {c1} -//FRAGMENT vbuz1=vbuc1_bor_vbuz2 -lda #{c1} -ora {z2} -sta {z1} -//FRAGMENT vwuz1_lt_vwuz2_then_la1 -lda {z1}+1 -cmp {z2}+1 -bcc {la1} -bne !+ -lda {z1} -cmp {z2} -bcc {la1} -!: -//FRAGMENT _deref_pbuc1=_deref_pbuc2 -lda {c2} -sta {c1} -//FRAGMENT vwuz1=_inc_vwuz1 -inc {z1} -bne !+ -inc {z1}+1 -!: -//FRAGMENT _deref_pduc1=vduc2 -lda #<{c2} -sta {c1} -lda #>{c2} -sta {c1}+1 -lda #<{c2}>>$10 -sta {c1}+2 -lda #>{c2}>>$10 -sta {c1}+3 -//FRAGMENT pbuz1=_deref_qbuc1 -lda {c1} -sta {z1} -lda {c1}+1 -sta {z1}+1 -//FRAGMENT vbuz1=_deref_pbuz2_band_vbuc1 -lda #{c1} -ldy #0 -and ({z2}),y -sta {z1} +sta {c1}+1,y //FRAGMENT pbuz1=pbuz2 lda {z2} sta {z1} @@ -359,12 +148,26 @@ bne {la1} lda {z1} cmp {z2} bcc {la1} +//FRAGMENT pwuc1_derefidx_vbuz1=vbuc2 +lda #{c2} +ldy {z1} +sta {c1},y +lda #0 +sta {c1}+1,y +//FRAGMENT _deref_pbuc1=_deref_pbuc1_band_vbuc2 +lda #{c2} +and {c1} +sta {c1} //FRAGMENT vbuz1=_lo_pbuz2 lda {z2} sta {z1} //FRAGMENT vbuz1=_hi_pbuz2 lda {z2}+1 sta {z1} +//FRAGMENT vbuz1=vbuz2_bor_vbuc1 +lda #{c1} +ora {z2} +sta {z1} //FRAGMENT pbuz1=pbuz1_plus_vwuz2 lda {z1} clc @@ -373,107 +176,30 @@ sta {z1} lda {z1}+1 adc {z2}+1 sta {z1}+1 -//FRAGMENT pbuz1_neq_pbuc1_then_la1 -lda {z1}+1 -cmp #>{c1} -bne {la1} -lda {z1} -cmp #<{c1} -bne {la1} -//FRAGMENT _deref_pbuc1=_deref_pbuz1 +//FRAGMENT vbuz1=_inc_vbuz1 +inc {z1} +//FRAGMENT vbuz1=_deref_pbuz2 ldy #0 -lda ({z1}),y -sta {c1} +lda ({z2}),y +sta {z1} //FRAGMENT pbuz1=_inc_pbuz1 inc {z1} bne !+ inc {z1}+1 !: -//FRAGMENT vduz1=_deref_pduc1 -lda {c1} -sta {z1} -lda {c1}+1 -sta {z1}+1 -lda {c1}+2 -sta {z1}+2 -lda {c1}+3 -sta {z1}+3 -//FRAGMENT vwuz1=vwuc1_rol_vbuz2 -ldy {z2} -lda #<{c1} -sta {z1} -lda #>{c1}+1 -sta {z1}+1 -cpy #0 -beq !e+ -!: -asl {z1} -rol {z1}+1 -dey -bne !- -!e: -//FRAGMENT vbuz1=_lo_vwuz2 -lda {z2} -sta {z1} -//FRAGMENT vduz1=vduz2_plus_vwuz3 -lda {z2} -clc -adc {z3} -sta {z1} -lda {z2}+1 -adc {z3}+1 -sta {z1}+1 -lda {z2}+2 -adc #0 -sta {z1}+2 -lda {z2}+3 -adc #0 -sta {z1}+3 -//FRAGMENT vduz1=vduz2_plus_vbuz3 -lda {z3} -clc -adc {z2} -sta {z1} -lda {z2}+1 -adc #0 -sta {z1}+1 -lda {z2}+2 -adc #0 -sta {z1}+2 -lda {z2}+3 -adc #0 -sta {z1}+3 -//FRAGMENT vduz1=vduz2 -lda {z2} -sta {z1} -lda {z2}+1 -sta {z1}+1 -lda {z2}+2 -sta {z1}+2 -lda {z2}+3 -sta {z1}+3 -//FRAGMENT vduz1=vduz1_plus_vwuz2 -lda {z1} -clc -adc {z2} -sta {z1} -lda {z1}+1 -adc {z2}+1 -sta {z1}+1 -lda {z1}+2 -adc #0 -sta {z1}+2 -lda {z1}+3 -adc #0 -sta {z1}+3 -//FRAGMENT vbuz1=_deref_pbuz2 -ldy #0 -lda ({z2}),y -sta {z1} //FRAGMENT 0_neq_vbuz1_then_la1 lda {z1} cmp #0 bne {la1} +//FRAGMENT pbuz1=_deref_qbuc1 +lda {c1} +sta {z1} +lda {c1}+1 +sta {z1}+1 +//FRAGMENT _deref_pbuz1=vbuc1 +lda #{c1} +ldy #0 +sta ({z1}),y //FRAGMENT vbuz1=pbuc1_derefidx_vbuz2 ldy {z2} lda {c1},y @@ -484,6 +210,11 @@ lda {c1},y sta {z1} lda {c1}+1,y sta {z1}+1 +//FRAGMENT vbuz1=_deref_pbuz2_band_vbuc1 +lda #{c1} +ldy #0 +and ({z2}),y +sta {z1} //FRAGMENT vbuz1=vbuz2_ror_4 lda {z2} lsr @@ -498,11 +229,9 @@ rol rol and #$03 sta {z1} -//FRAGMENT vbuz1=_lo__deref_pwuc1 -lda {c1} -sta {z1} -//FRAGMENT vbuz1=_hi__deref_pwuc1 -lda {c1}+1 +//FRAGMENT vbuz1=vbuz2_band_vbuc1 +lda #{c1} +and {z2} sta {z1} //FRAGMENT pbuz1=pbuz2_plus_pwuc1_derefidx_vbuz3 ldy {z3} @@ -526,6 +255,10 @@ sta {z1} lda #0 adc {z2}+1 sta {z1}+1 +//FRAGMENT vbuz1_eq_vbuc1_then_la1 +lda #{c1} +cmp {z1} +beq {la1} //FRAGMENT pbuc1_derefidx_vbuz1=_inc_pbuc1_derefidx_vbuz1 ldx {z1} inc {c1},x @@ -547,6 +280,31 @@ lda {z2} ldy {z1} cmp {c1},y bne {la1} +//FRAGMENT vbuz1_lt_vbuc1_then_la1 +lda {z1} +cmp #{c1} +bcc {la1} +//FRAGMENT _deref_pbuz1=pbuc1_derefidx_vbuz2 +ldy {z2} +lda {c1},y +ldy #0 +sta ({z1}),y +//FRAGMENT pbuz1=_inc_pbuz2 +clc +lda {z2} +adc #1 +sta {z1} +lda {z2}+1 +adc #0 +sta {z1}+1 +//FRAGMENT vbuz1_ge_vbuz2_then_la1 +lda {z1} +cmp {z2} +bcs {la1} +//FRAGMENT 0_eq_vbuz1_then_la1 +lda {z1} +cmp #0 +beq {la1} //FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_rol_4 ldy {z2} lda {c1},y @@ -568,6 +326,11 @@ sta {z1} lda {z2}+1 adc {z3}+1 sta {z1}+1 +//FRAGMENT vbuz1=vbuz1_minus_vbuz2 +lda {z1} +sec +sbc {z2} +sta {z1} //FRAGMENT pbuc1_derefidx_vbuz1_lt_vbuz2_then_la1 ldy {z1} lda {c1},y @@ -607,6 +370,11 @@ sta {z1} lda {z2}+1 adc {z3}+1 sta {z1}+1 +//FRAGMENT pvoz1=pvoz2 +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 //FRAGMENT vwuz1=vbuz2 lda {z2} sta {z1} @@ -619,344 +387,46 @@ lda {z1} cmp {z2} bcc {la1} !: +//FRAGMENT vwuz1=_inc_vwuz1 +inc {z1} +bne !+ +inc {z1}+1 +!: +//FRAGMENT vbuz1=_lo_pvoz2 +lda {z2} +sta {z1} +//FRAGMENT vbuz1=_hi_pvoz2 +lda {z2}+1 +sta {z1} +//FRAGMENT _deref_pbuc1=_deref_pbuc1_bor_vbuc2 +lda #{c2} +ora {c1} +sta {c1} +//FRAGMENT vwuz1_lt_vwuz2_then_la1 +lda {z1}+1 +cmp {z2}+1 +bcc {la1} +bne !+ +lda {z1} +cmp {z2} +bcc {la1} +!: +//FRAGMENT _deref_pbuc1=_deref_pbuc2 +lda {c2} +sta {c1} //FRAGMENT vbuaa=_deref_pbuc1 lda {c1} //FRAGMENT vbuxx=_deref_pbuc1 ldx {c1} -//FRAGMENT vbuxx_lt_vbuz1_then_la1 -cpx {z1} +//FRAGMENT vbuaa_lt_vbuz1_then_la1 +cmp {z1} bcc {la1} -//FRAGMENT vbuxx=vbuz1_minus_1 -ldx {z1} -dex -//FRAGMENT vbuyy=vbuz1_minus_1 +//FRAGMENT vbuaa=vbuz1_minus_1 lda {z1} -tay -dey -//FRAGMENT vbuz1=vbuxx -stx {z1} -//FRAGMENT vbuaa=vbuz1 -lda {z1} -//FRAGMENT vbuxx=vbuz1 -ldx {z1} +sec +sbc #1 //FRAGMENT vbuz1=vbuaa sta {z1} -//FRAGMENT 0_eq_vbuaa_then_la1 -cmp #0 -beq {la1} -//FRAGMENT pbuc1_derefidx_vbuaa=pbuc1_derefidx_vbuaa_plus_1 -tay -lda {c1},y -inc -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=pbuc1_derefidx_vbuxx_plus_1 -lda {c1},x -inc -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=pbuc1_derefidx_vbuyy_plus_1 -lda {c1},y -inc -sta {c1},y -//FRAGMENT vbuxx_neq_0_then_la1 -cpx #0 -bne {la1} -//FRAGMENT vbuxx_neq_vbuc1_then_la1 -cpx #{c1} -bne {la1} -//FRAGMENT vbuxx=vbuxx_plus_2 -inx -inx -//FRAGMENT vbuaa_eq_vbuc1_then_la1 -cmp #{c1} -beq {la1} -//FRAGMENT vbuaa_neq_vbuc1_then_la1 -cmp #{c1} -bne {la1} -//FRAGMENT vbuxx=vbuxx_bor_vbuc1 -txa -ora #{c1} -tax -//FRAGMENT vbuyy=vbuyy_bor_vbuc1 -tya -ora #{c1} -tay -//FRAGMENT pbuc1_derefidx_vbuxx=vbuc2 -lda #{c2} -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuc2 -lda #{c2} -sta {c1},y -//FRAGMENT vbuz1=vbuxx_rol_1 -txa -asl -sta {z1} -//FRAGMENT vbuz1=vbuyy_rol_1 -tya -asl -sta {z1} -//FRAGMENT vbuaa=vbuz1_rol_1 -lda {z1} -asl -//FRAGMENT vbuaa=vbuxx_rol_1 -txa -asl -//FRAGMENT vbuaa=vbuyy_rol_1 -tya -asl -//FRAGMENT vbuxx=vbuz1_rol_1 -lda {z1} -asl -tax -//FRAGMENT vbuxx=vbuxx_rol_1 -txa -asl -tax -//FRAGMENT vbuxx=vbuyy_rol_1 -tya -asl -tax -//FRAGMENT vbuyy=vbuz1_rol_1 -lda {z1} -asl -tay -//FRAGMENT vbuyy=vbuxx_rol_1 -txa -asl -tay -//FRAGMENT vbuyy=vbuyy_rol_1 -tya -asl -tay -//FRAGMENT pwuc1_derefidx_vbuaa=vwuc2 -tay -lda #<{c2} -sta {c1},y -lda #>{c2} -sta {c1}+1,y -//FRAGMENT pwuc1_derefidx_vbuxx=vwuc2 -lda #<{c2} -sta {c1},x -lda #>{c2} -sta {c1}+1,x -//FRAGMENT pwuc1_derefidx_vbuyy=vwuc2 -lda #<{c2} -sta {c1},y -lda #>{c2} -sta {c1}+1,y -//FRAGMENT vbuaa=vbuz1_bor_vbuc1 -lda #{c1} -ora {z1} -//FRAGMENT vbuxx=vbuz1_bor_vbuc1 -lda #{c1} -ora {z1} -tax -//FRAGMENT vbuyy=vbuz1_bor_vbuc1 -lda #{c1} -ora {z1} -tay -//FRAGMENT vbuz1=vbuxx_bor_vbuc1 -txa -ora #{c1} -sta {z1} -//FRAGMENT vbuaa=vbuxx_bor_vbuc1 -txa -ora #{c1} -//FRAGMENT vbuyy=vbuxx_bor_vbuc1 -txa -ora #{c1} -tay -//FRAGMENT vbuz1=vbuyy_bor_vbuc1 -tya -ora #{c1} -sta {z1} -//FRAGMENT vbuaa=vbuyy_bor_vbuc1 -tya -ora #{c1} -//FRAGMENT vbuxx=vbuyy_bor_vbuc1 -tya -ora #{c1} -tax -//FRAGMENT pwuc1_derefidx_vbuaa=vwuz1 -tay -lda {z1} -sta {c1},y -lda {z1}+1 -sta {c1}+1,y -//FRAGMENT pwuc1_derefidx_vbuxx=vwuz1 -lda {z1} -sta {c1},x -lda {z1}+1 -sta {c1}+1,x -//FRAGMENT pwuc1_derefidx_vbuyy=vwuz1 -lda {z1} -sta {c1},y -lda {z1}+1 -sta {c1}+1,y -//FRAGMENT pbuc1_derefidx_vbuxx=_byte_vwuz1 -lda {z1} -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=_byte_vwuz1 -lda {z1} -sta {c1},y -//FRAGMENT vbuz1=vbuxx_rol_2 -txa -asl -asl -sta {z1} -//FRAGMENT vbuz1=vbuyy_rol_2 -tya -asl -asl -sta {z1} -//FRAGMENT vbuaa=vbuz1_rol_2 -lda {z1} -asl -asl -//FRAGMENT vbuaa=vbuxx_rol_2 -txa -asl -asl -//FRAGMENT vbuaa=vbuyy_rol_2 -tya -asl -asl -//FRAGMENT vbuxx=vbuz1_rol_2 -lda {z1} -asl -asl -tax -//FRAGMENT vbuxx=vbuxx_rol_2 -txa -asl -asl -tax -//FRAGMENT vbuxx=vbuyy_rol_2 -tya -asl -asl -tax -//FRAGMENT vbuyy=vbuz1_rol_2 -lda {z1} -asl -asl -tay -//FRAGMENT vbuyy=vbuxx_rol_2 -txa -asl -asl -tay -//FRAGMENT vbuyy=vbuyy_rol_2 -tya -asl -asl -tay -//FRAGMENT pduc1_derefidx_vbuaa=vduz1 -tax -lda {z1} -sta {c1},x -lda {z1}+1 -sta {c1}+1,x -lda {z1}+2 -sta {c1}+2,x -lda {z1}+3 -sta {c1}+3,x -//FRAGMENT pduc1_derefidx_vbuxx=vduz1 -lda {z1} -sta {c1},x -lda {z1}+1 -sta {c1}+1,x -lda {z1}+2 -sta {c1}+2,x -lda {z1}+3 -sta {c1}+3,x -//FRAGMENT pduc1_derefidx_vbuyy=vduz1 -tya -tax -lda {z1} -sta {c1},x -lda {z1}+1 -sta {c1}+1,x -lda {z1}+2 -sta {c1}+2,x -lda {z1}+3 -sta {c1}+3,x -//FRAGMENT vbuaa=_hi_vwuz1 -lda {z1}+1 -//FRAGMENT vbuxx=_hi_vwuz1 -ldx {z1}+1 -//FRAGMENT vbuz1=vbuaa_band_vbuc1 -and #{c1} -sta {z1} -//FRAGMENT vbuz1=vbuxx_band_vbuc1 -txa -and #{c1} -sta {z1} -//FRAGMENT vbuz1=vbuyy_band_vbuc1 -tya -and #{c1} -sta {z1} -//FRAGMENT vbuaa=vbuz1_band_vbuc1 -lda #{c1} -and {z1} -//FRAGMENT vbuaa=vbuaa_band_vbuc1 -and #{c1} -//FRAGMENT vbuaa=vbuxx_band_vbuc1 -txa -and #{c1} -//FRAGMENT vbuaa=vbuyy_band_vbuc1 -tya -and #{c1} -//FRAGMENT vbuxx=vbuz1_band_vbuc1 -lda #{c1} -and {z1} -tax -//FRAGMENT vbuxx=vbuaa_band_vbuc1 -and #{c1} -tax -//FRAGMENT vbuxx=vbuxx_band_vbuc1 -txa -and #{c1} -tax -//FRAGMENT vbuxx=vbuyy_band_vbuc1 -tya -and #{c1} -tax -//FRAGMENT vbuyy=vbuz1_band_vbuc1 -lda #{c1} -and {z1} -tay -//FRAGMENT vbuyy=vbuaa_band_vbuc1 -and #{c1} -tay -//FRAGMENT vbuyy=vbuxx_band_vbuc1 -txa -and #{c1} -tay -//FRAGMENT vbuyy=vbuyy_band_vbuc1 -tya -and #{c1} -tay -//FRAGMENT vbuxx_eq_vbuc1_then_la1 -cpx #{c1} -beq {la1} -//FRAGMENT vbuaa=vbuaa_bor_vbuc1 -ora #{c1} -//FRAGMENT pwuc1_derefidx_vbuaa=vbuc2 -tay -lda #{c2} -sta {c1},y -lda #0 -sta {c1}+1,y -//FRAGMENT pwuc1_derefidx_vbuxx=vbuc2 -lda #{c2} -sta {c1},x -lda #0 -sta {c1}+1,x -//FRAGMENT pwuc1_derefidx_vbuyy=vbuc2 -lda #{c2} -sta {c1},y -lda #0 -sta {c1}+1,y //FRAGMENT vbuaa=_deref_pbuc1_ror_7 lda {c1} rol @@ -1129,48 +599,21 @@ bne !- tay //FRAGMENT _deref_pbuc1=vbuaa sta {c1} -//FRAGMENT pbuc1_derefidx_vbuaa=vbuc2 -tay -lda #{c2} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuaa=vbuz1 -tay +//FRAGMENT vbuaa=vbuz1 lda {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=vbuz1 +//FRAGMENT vbuxx=vbuz1 +ldx {z1} +//FRAGMENT vbuaa=vbuz1_rol_1 lda {z1} -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuz1 +asl +//FRAGMENT vbuxx=vbuz1_rol_1 lda {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuz1=vbuxx -ldy {z1} -txa -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuaa=vbuxx -tay -txa -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=vbuxx -txa -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuxx -txa -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuz1=vbuyy -tya -ldy {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuaa=vbuyy +asl tax -tya -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuxx=vbuyy -tya -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuyy -tya -sta {c1},y +//FRAGMENT vbuyy=vbuz1_rol_1 +lda {z1} +asl +tay //FRAGMENT vbuz1=vbuaa_rol_1 asl sta {z1} @@ -1182,6 +625,36 @@ tax //FRAGMENT vbuyy=vbuaa_rol_1 asl tay +//FRAGMENT vbuz1=vbuxx_rol_1 +txa +asl +sta {z1} +//FRAGMENT vbuaa=vbuxx_rol_1 +txa +asl +//FRAGMENT vbuxx=vbuxx_rol_1 +txa +asl +tax +//FRAGMENT vbuyy=vbuxx_rol_1 +txa +asl +tay +//FRAGMENT vbuz1=vbuyy_rol_1 +tya +asl +sta {z1} +//FRAGMENT vbuaa=vbuyy_rol_1 +tya +asl +//FRAGMENT vbuxx=vbuyy_rol_1 +tya +asl +tax +//FRAGMENT vbuyy=vbuyy_rol_1 +tya +asl +tay //FRAGMENT pbuz1=qbuc1_derefidx_vbuaa tay lda {c1},y @@ -1211,87 +684,31 @@ ldy {z1} sta $ff cpy $ff bcs {la1} +//FRAGMENT pbuc1_derefidx_vbuz1=vbuxx +ldy {z1} +txa +sta {c1},y //FRAGMENT vwuz1=_word_vbuxx txa sta {z1} lda #0 sta {z1}+1 -//FRAGMENT vbuaa=_lo_pvoz1 +//FRAGMENT pwuc1_derefidx_vbuaa=vwuz1 +tay lda {z1} -//FRAGMENT vbuxx=_lo_pvoz1 -ldx {z1} -//FRAGMENT vbuaa=_hi_pvoz1 +sta {c1},y lda {z1}+1 -//FRAGMENT vbuxx=_hi_pvoz1 -ldx {z1}+1 -//FRAGMENT _deref_pbuc1=vbuxx -stx {c1} -//FRAGMENT vbuz1=vbuc1_bor_vbuxx -txa -ora #{c1} -sta {z1} -//FRAGMENT vbuz1=vbuc1_bor_vbuyy -tya -ora #{c1} -sta {z1} -//FRAGMENT vbuaa=vbuc1_bor_vbuz1 -lda #{c1} -ora {z1} -//FRAGMENT vbuaa=vbuc1_bor_vbuxx -txa -ora #{c1} -//FRAGMENT vbuaa=vbuc1_bor_vbuyy -tya -ora #{c1} -//FRAGMENT vbuxx=vbuc1_bor_vbuz1 -lda #{c1} -ora {z1} -tax -//FRAGMENT vbuxx=vbuc1_bor_vbuxx -txa -ora #{c1} -tax -//FRAGMENT vbuxx=vbuc1_bor_vbuyy -tya -ora #{c1} -tax -//FRAGMENT vbuyy=vbuc1_bor_vbuz1 -lda #{c1} -ora {z1} -tay -//FRAGMENT vbuyy=vbuc1_bor_vbuxx -txa -ora #{c1} -tay -//FRAGMENT vbuyy=vbuc1_bor_vbuyy -tya -ora #{c1} -tay -//FRAGMENT vbuaa=_deref_pbuz1_band_vbuc1 -lda #{c1} -ldy #0 -and ({z1}),y -//FRAGMENT vbuxx=_deref_pbuz1_band_vbuc1 -lda #{c1} -ldy #0 -and ({z1}),y -tax -//FRAGMENT vbuyy=_deref_pbuz1_band_vbuc1 -lda #{c1} -ldy #0 -and ({z1}),y -tay -//FRAGMENT vbuz1=vbuc1_bor_vbuaa -ora #{c1} -sta {z1} -//FRAGMENT vbuaa=vbuc1_bor_vbuaa -ora #{c1} -//FRAGMENT vbuxx=vbuc1_bor_vbuaa -ora #{c1} -tax -//FRAGMENT vbuyy=vbuc1_bor_vbuaa -ora #{c1} -tay +sta {c1}+1,y +//FRAGMENT pwuc1_derefidx_vbuxx=vwuz1 +lda {z1} +sta {c1},x +lda {z1}+1 +sta {c1}+1,x +//FRAGMENT pwuc1_derefidx_vbuyy=vwuz1 +lda {z1} +sta {c1},y +lda {z1}+1 +sta {c1}+1,y //FRAGMENT vbuz1=vbuaa_rol_4 asl asl @@ -1459,6 +876,22 @@ ldy {z1}+1 bne {la1} cmp {z1} bcc {la1} +//FRAGMENT pwuc1_derefidx_vbuaa=vbuc2 +tay +lda #{c2} +sta {c1},y +lda #0 +sta {c1}+1,y +//FRAGMENT pwuc1_derefidx_vbuxx=vbuc2 +lda #{c2} +sta {c1},x +lda #0 +sta {c1}+1,x +//FRAGMENT pwuc1_derefidx_vbuyy=vbuc2 +lda #{c2} +sta {c1},y +lda #0 +sta {c1}+1,y //FRAGMENT vbuaa=_lo_pbuz1 lda {z1} //FRAGMENT vbuxx=_lo_pbuz1 @@ -1467,155 +900,34 @@ ldx {z1} lda {z1}+1 //FRAGMENT vbuxx=_hi_pbuz1 ldx {z1}+1 -//FRAGMENT vwuz1=vwuc1_rol_vbuaa -tay -lda #<{c1} -sta {z1} -lda #>{c1}+1 -sta {z1}+1 -cpy #0 -beq !e+ -!: -asl {z1} -rol {z1}+1 -dey -bne !- -!e: -//FRAGMENT vwuz1=vwuc1_rol_vbuxx -lda #<{c1} -sta {z1} -lda #>{c1}+1 -sta {z1}+1 -cpx #0 -beq !e+ -!: -asl {z1} -rol {z1}+1 -dex -bne !- -!e: -//FRAGMENT vwuz1=vwuc1_rol_vbuyy -lda #<{c1} -sta {z1} -lda #>{c1}+1 -sta {z1}+1 -cpy #0 -beq !e+ -!: -asl {z1} -rol {z1}+1 -dey -bne !- -!e: -//FRAGMENT vbuaa=_lo_vwuz1 -lda {z1} -//FRAGMENT vbuxx=_lo_vwuz1 -ldx {z1} -//FRAGMENT vbuz1=vbuxx_bor_vbuz2 +//FRAGMENT vbuz1=vbuxx_bor_vbuc1 txa -ora {z2} +ora #{c1} sta {z1} -//FRAGMENT vbuz1=vbuyy_bor_vbuz2 -tya -ora {z2} -sta {z1} -//FRAGMENT vbuaa=vbuxx_bor_vbuz1 -txa +//FRAGMENT vbuaa=vbuz1_bor_vbuc1 +lda #{c1} ora {z1} -//FRAGMENT vbuaa=vbuyy_bor_vbuz1 -tya -ora {z1} -//FRAGMENT vbuxx=vbuxx_bor_vbuz1 +//FRAGMENT vbuaa=vbuxx_bor_vbuc1 txa +ora #{c1} +//FRAGMENT vbuxx=vbuz1_bor_vbuc1 +lda #{c1} ora {z1} tax -//FRAGMENT vbuxx=vbuyy_bor_vbuz1 -tya -ora {z1} +//FRAGMENT vbuxx=vbuxx_bor_vbuc1 +txa +ora #{c1} tax -//FRAGMENT vbuyy=vbuxx_bor_vbuz1 -txa +//FRAGMENT vbuyy=vbuz1_bor_vbuc1 +lda #{c1} ora {z1} tay -//FRAGMENT vbuyy=vbuyy_bor_vbuz1 -tya -ora {z1} -tay -//FRAGMENT vwuz1=_word_vbuyy -tya -sta {z1} -lda #0 -sta {z1}+1 -//FRAGMENT vwuz1=vwuz2_rol_vbuxx -lda {z2} -sta {z1} -lda {z2}+1 -sta {z1}+1 -cpx #0 -beq !e+ -!: -asl {z1} -rol {z1}+1 -dex -bne !- -!e: -//FRAGMENT vwuz1=vwuz2_rol_vbuyy -lda {z2} -sta {z1} -lda {z2}+1 -sta {z1}+1 -cpy #0 -beq !e+ -!: -asl {z1} -rol {z1}+1 -dey -bne !- -!e: -//FRAGMENT vduz1=vduz2_plus_vbuaa -clc -adc {z2} -sta {z1} -lda {z2}+1 -adc #0 -sta {z1}+1 -lda {z2}+2 -adc #0 -sta {z1}+2 -lda {z2}+3 -adc #0 -sta {z1}+3 -//FRAGMENT vduz1=vduz2_plus_vbuxx +//FRAGMENT vbuyy=vbuxx_bor_vbuc1 txa -clc -adc {z2} -sta {z1} -lda {z2}+1 -adc #0 -sta {z1}+1 -lda {z2}+2 -adc #0 -sta {z1}+2 -lda {z2}+3 -adc #0 -sta {z1}+3 -//FRAGMENT vduz1=vduz2_plus_vbuyy -tya -clc -adc {z2} -sta {z1} -lda {z2}+1 -adc #0 -sta {z1}+1 -lda {z2}+2 -adc #0 -sta {z1}+2 -lda {z2}+3 -adc #0 -sta {z1}+3 -//FRAGMENT vbuaa_lt_vbuz1_then_la1 -cmp {z1} -bcc {la1} +ora #{c1} +tay +//FRAGMENT _deref_pbuc1=vbuxx +stx {c1} //FRAGMENT vbuaa=_deref_pbuz1 ldy #0 lda ({z1}),y @@ -1630,6 +942,8 @@ tay //FRAGMENT 0_neq_vbuaa_then_la1 cmp #0 bne {la1} +//FRAGMENT vbuz1=vbuxx +stx {z1} //FRAGMENT vbuz1=pbuc1_derefidx_vbuaa tay lda {c1},y @@ -1669,6 +983,20 @@ lda {c1},y sta {z1} lda {c1}+1,y sta {z1}+1 +//FRAGMENT vbuaa=_deref_pbuz1_band_vbuc1 +lda #{c1} +ldy #0 +and ({z1}),y +//FRAGMENT vbuxx=_deref_pbuz1_band_vbuc1 +lda #{c1} +ldy #0 +and ({z1}),y +tax +//FRAGMENT vbuyy=_deref_pbuz1_band_vbuc1 +lda #{c1} +ldy #0 +and ({z1}),y +tay //FRAGMENT vbuz1=vbuaa_ror_4 lsr lsr @@ -1872,22 +1200,57 @@ rol rol and #$03 tay -//FRAGMENT vbuaa=_lo__deref_pwuc1 -lda {c1} -//FRAGMENT vbuxx=_lo__deref_pwuc1 -ldx {c1} -//FRAGMENT vbuaa=_hi__deref_pwuc1 -lda {c1}+1 -//FRAGMENT vbuxx=_hi__deref_pwuc1 -ldx {c1}+1 -//FRAGMENT vbuz1=vbuaa_bor_vbuc1 -ora #{c1} -sta {z1} -//FRAGMENT vbuxx=vbuaa_bor_vbuc1 -ora #{c1} +//FRAGMENT vbuaa=vbuz1_band_vbuc1 +lda #{c1} +and {z1} +//FRAGMENT vbuxx=vbuz1_band_vbuc1 +lda #{c1} +and {z1} tax -//FRAGMENT vbuyy=vbuaa_bor_vbuc1 -ora #{c1} +//FRAGMENT vbuyy=vbuz1_band_vbuc1 +lda #{c1} +and {z1} +tay +//FRAGMENT vbuz1=vbuaa_band_vbuc1 +and #{c1} +sta {z1} +//FRAGMENT vbuaa=vbuaa_band_vbuc1 +and #{c1} +//FRAGMENT vbuxx=vbuaa_band_vbuc1 +and #{c1} +tax +//FRAGMENT vbuyy=vbuaa_band_vbuc1 +and #{c1} +tay +//FRAGMENT vbuz1=vbuxx_band_vbuc1 +txa +and #{c1} +sta {z1} +//FRAGMENT vbuaa=vbuxx_band_vbuc1 +txa +and #{c1} +//FRAGMENT vbuxx=vbuxx_band_vbuc1 +txa +and #{c1} +tax +//FRAGMENT vbuyy=vbuxx_band_vbuc1 +txa +and #{c1} +tay +//FRAGMENT vbuz1=vbuyy_band_vbuc1 +tya +and #{c1} +sta {z1} +//FRAGMENT vbuaa=vbuyy_band_vbuc1 +tya +and #{c1} +//FRAGMENT vbuxx=vbuyy_band_vbuc1 +tya +and #{c1} +tax +//FRAGMENT vbuyy=vbuyy_band_vbuc1 +tya +and #{c1} tay //FRAGMENT pbuz1=pbuz2_plus_pwuc1_derefidx_vbuaa tay @@ -1951,6 +1314,31 @@ sta {z1} lda #0 adc {z2}+1 sta {z1}+1 +//FRAGMENT vbuxx_eq_vbuc1_then_la1 +cpx #{c1} +beq {la1} +//FRAGMENT vbuaa_lt_vbuc1_then_la1 +cmp #{c1} +bcc {la1} +//FRAGMENT _deref_pbuz1=pbuc1_derefidx_vbuaa +tay +lda {c1},y +ldy #0 +sta ({z1}),y +//FRAGMENT _deref_pbuz1=pbuc1_derefidx_vbuxx +lda {c1},x +ldy #0 +sta ({z1}),y +//FRAGMENT _deref_pbuz1=pbuc1_derefidx_vbuyy +lda {c1},y +ldy #0 +sta ({z1}),y +//FRAGMENT vbuaa_ge_vbuz1_then_la1 +cmp {z1} +bcs {la1} +//FRAGMENT 0_eq_vbuaa_then_la1 +cmp #0 +beq {la1} //FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_rol_4 ldy {z1} lda {c1},y @@ -2238,13 +1626,49 @@ tax tya ora {c1},y tay +//FRAGMENT vbuxx=vbuxx_minus_vbuz1 +txa +sec +sbc {z1} +tax +//FRAGMENT vbuz1=vbuz1_minus_vbuaa +eor #$ff +sec +adc {z1} +sta {z1} +//FRAGMENT vbuxx=vbuxx_minus_vbuaa +sta $ff +txa +sec +sbc $ff +tax +//FRAGMENT vbuz1=vbuz1_minus_vbuxx +txa +eor #$ff +sec +adc {z1} +sta {z1} +//FRAGMENT vbuxx=vbuxx_minus_vbuxx +lda #0 +tax +//FRAGMENT vbuz1=vbuz1_minus_vbuyy +tya +eor #$ff +sec +adc {z1} +sta {z1} +//FRAGMENT vbuxx=vbuxx_minus_vbuyy +txa +sty $ff +sec +sbc $ff +tax +//FRAGMENT vbuxx=vbuz1_minus_1 +ldx {z1} +dex //FRAGMENT vbuz1_le_vbuxx_then_la1 cpx {z1} bcs {la1} -//FRAGMENT vbuaa=vbuz1_minus_1 -lda {z1} -sec -sbc #1 //FRAGMENT vwuz1=vbuaa_rol_vbuz2 ldy {z2} sta {z1} @@ -2291,11 +1715,34 @@ txa sta {z1} lda #0 sta {z1}+1 +//FRAGMENT vbuaa=_lo_pvoz1 +lda {z1} +//FRAGMENT vbuxx=_lo_pvoz1 +ldx {z1} +//FRAGMENT vbuaa=_hi_pvoz1 +lda {z1}+1 +//FRAGMENT vbuxx=_hi_pvoz1 +ldx {z1}+1 +//FRAGMENT vbuxx_lt_vbuz1_then_la1 +cpx {z1} +bcc {la1} //FRAGMENT vbuxx_le_vbuz1_then_la1 lda {z1} stx $ff cmp $ff bcs {la1} +//FRAGMENT vbuz1=vbuxx_bor_vbuz2 +txa +ora {z2} +sta {z1} +//FRAGMENT vbuxx=vbuxx_bor_vbuz1 +txa +ora {z1} +tax +//FRAGMENT vbuyy=vbuxx_bor_vbuz1 +txa +ora {z1} +tay //FRAGMENT vbuz1=vbuxx_bor_vbuaa stx $ff ora $ff @@ -2320,6 +1767,12 @@ lda {z1}+1 bne {la1} cpy {z1} bcc {la1} +//FRAGMENT vbuxx_lt_vbuc1_then_la1 +cpx #{c1} +bcc {la1} +//FRAGMENT vbuxx_ge_vbuz1_then_la1 +cpx {z1} +bcs {la1} //FRAGMENT vbuyy=_lo_pvoz1 ldy {z1} //FRAGMENT _deref_pbuc1=vbuyy @@ -2341,46 +1794,53 @@ inx txa sec sbc #1 +//FRAGMENT vbuyy=vbuz1_minus_1 +lda {z1} +tay +dey //FRAGMENT vbuyy=vbuxx_minus_1 txa tay dey -//FRAGMENT vbuyy=_lo__deref_pwuc1 -ldy {c1} -//FRAGMENT vbuyy=_hi__deref_pwuc1 -ldy {c1}+1 -//FRAGMENT vbuaa=vbuc1 -lda #{c1} -//FRAGMENT vbuaa=_inc_vbuaa -inc //FRAGMENT vbuyy=vbuc1 ldy #{c1} -//FRAGMENT vbuyy_lt_vbuz1_then_la1 -cpy {z1} -bcc {la1} //FRAGMENT vbuyy=_inc_vbuyy iny -//FRAGMENT vbuyy=_lo_vwuz1 -ldy {z1} -//FRAGMENT vbuyy_neq_0_then_la1 -cpy #0 -bne {la1} -//FRAGMENT vbuxx=vbuyy -tya -tax -//FRAGMENT vbuz1=vbuyy -sty {z1} +//FRAGMENT vbuz1_ge_vbuxx_then_la1 +lda {z1} +stx $ff +cmp $ff +bcs {la1} +//FRAGMENT vbuz1_ge_vbuyy_then_la1 +lda {z1} +sty $ff +cmp $ff +bcs {la1} +//FRAGMENT vbuxx_ge_vbuyy_then_la1 +sty $ff +cpx $ff +bcs {la1} //FRAGMENT vbuaa=vbuxx txa -//FRAGMENT vbuaa=vbuyy -tya -//FRAGMENT vbuxx=vbuaa -tax -//FRAGMENT vbuyy=vbuaa -tay +//FRAGMENT vbuz1=vbuyy +sty {z1} //FRAGMENT vbuyy=vbuxx txa tay +//FRAGMENT 0_neq_vbuxx_then_la1 +cpx #0 +bne {la1} +//FRAGMENT 0_neq_vbuyy_then_la1 +cpy #0 +bne {la1} +//FRAGMENT vbuyy_ge_vbuz1_then_la1 +cpy {z1} +bcs {la1} +//FRAGMENT vbuxx=vbuyy +tya +tax +//FRAGMENT vbuaa=vbuc1 +lda #{c1} //FRAGMENT vbuxx=pbuc1_derefidx_vbuxx lda {c1},x tax @@ -2391,63 +1851,27 @@ ldy {c1},x //FRAGMENT vbuyy=pbuc1_derefidx_vbuyy lda {c1},y tay -//FRAGMENT 0_neq_vbuxx_then_la1 -cpx #0 -bne {la1} -//FRAGMENT 0_neq_vbuyy_then_la1 -cpy #0 -bne {la1} -//FRAGMENT vbuyy=_hi_vwuz1 -ldy {z1}+1 -//FRAGMENT vbuyy=_deref_pbuc1 -ldy {c1} -//FRAGMENT vbuaa=vbuaa_bor_vbuyy -sty $ff -ora $ff -//FRAGMENT vbuz1=vbuaa_bor_vbuyy -sty $ff -ora $ff -sta {z1} -//FRAGMENT vbuyy_eq_vbuc1_then_la1 -cpy #{c1} -beq {la1} +//FRAGMENT vbuaa=vbuyy +tya +//FRAGMENT vbuxx=vbuaa +tax +//FRAGMENT vbuyy=vbuaa +tay //FRAGMENT 0_eq_vbuxx_then_la1 cpx #0 beq {la1} +//FRAGMENT vbuyy=_deref_pbuc1 +ldy {c1} //FRAGMENT 0_eq_vbuyy_then_la1 cpy #0 beq {la1} -//FRAGMENT vbuyy_neq_vbuc1_then_la1 +//FRAGMENT vbuyy_eq_vbuc1_then_la1 cpy #{c1} -bne {la1} +beq {la1} //FRAGMENT vbuz1=vbuyy_bor_vbuaa sty $ff ora $ff sta {z1} -//FRAGMENT vwuz1=vwuz1_band_vbuc1 -lda #{c1} -and {z1} -sta {z1} -lda #0 -sta {z1}+1 -//FRAGMENT vduz1=vduz1_ror_1 -lsr {z1}+3 -ror {z1}+2 -ror {z1}+1 -ror {z1} -//FRAGMENT vduz1=vduz1_plus_vbuaa -clc -adc {z1} -sta {z1} -lda {z1}+1 -adc #0 -sta {z1}+1 -lda {z1}+2 -adc #0 -sta {z1}+2 -lda {z1}+3 -adc #0 -sta {z1}+3 //FRAGMENT vwuz1=vwuz1_rol_vbuz2 ldy {z2} beq !e+ @@ -2460,9 +1884,6 @@ bne !- //FRAGMENT vbuz1=vbuz1_bor_vbuaa ora {z1} sta {z1} -//FRAGMENT vbuz1=vbuaa_bor_vbuz1 -ora {z1} -sta {z1} //FRAGMENT pbuz1=pbuz1_plus_vbuaa clc adc {z1} @@ -2486,76 +1907,181 @@ sta {z1} lda {z1}+1 adc {z2}+1 sta {z1}+1 -//FRAGMENT vduz1=vwsc1 +//FRAGMENT _deref_pduc1=vwuc2 NO_SYNTHESIS -//FRAGMENT vbuz1=vbuaa_bor_vbuxx -stx $ff -ora $ff +//FRAGMENT vduz1=_deref_pduc1 +lda {c1} sta {z1} -//FRAGMENT vbuaa=vbuaa_bor_vbuxx -stx $ff -ora $ff -//FRAGMENT vbuxx=vbuaa_bor_vbuxx -stx $ff -ora $ff -tax -//FRAGMENT vbuyy=vbuaa_bor_vbuxx -stx $ff -ora $ff -tay -//FRAGMENT vbuxx=vbuaa_bor_vbuyy -sty $ff -ora $ff -tax -//FRAGMENT vbuyy=vbuaa_bor_vbuyy -sty $ff -ora $ff -tay -//FRAGMENT vbuz1=vbuz1_plus_1 -inc {z1} -//FRAGMENT vwuz1_lt_vwuc1_then_la1 +lda {c1}+1 +sta {z1}+1 +lda {c1}+2 +sta {z1}+2 +lda {c1}+3 +sta {z1}+3 +//FRAGMENT vduz1=vduz2 +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 +lda {z2}+2 +sta {z1}+2 +lda {z2}+3 +sta {z1}+3 +//FRAGMENT vbuz1=_byte_vduz2 +lda {z2} +sta {z1} +//FRAGMENT vbuz1=vbuz2_rol_2 +lda {z2} +asl +asl +sta {z1} +//FRAGMENT vduz1=pduc1_derefidx_vbuz2 +ldy {z2} +lda {c1},y +sta {z1} +lda {c1}+1,y +sta {z1}+1 +lda {c1}+2,y +sta {z1}+2 +lda {c1}+3,y +sta {z1}+3 +//FRAGMENT vduz1_ge_vduz2_then_la1 +lda {z1}+3 +cmp {z2}+3 +bcc !+ +bne {la1} +lda {z1}+2 +cmp {z2}+2 +bcc !+ +bne {la1} lda {z1}+1 -cmp #>{c1} -bcc {la1} -bne !+ +cmp {z2}+1 +bcc !+ +bne {la1} lda {z1} -cmp #<{c1} -bcc {la1} +cmp {z2} +bcs {la1} !: -//FRAGMENT vbuz1=_bnot__deref_pbuc1 -lda {c1} -eor #$ff +//FRAGMENT vduz1=vduz1_minus_vduz2 +lda {z1} +sec +sbc {z2} sta {z1} -//FRAGMENT _deref_pbuc1=_deref_pbuc1_band_vbuz1 -lda {c1} -and {z1} -sta {c1} -//FRAGMENT vbuaa=_bnot__deref_pbuc1 -lda {c1} -eor #$ff -//FRAGMENT vbuxx=_bnot__deref_pbuc1 -lda {c1} -eor #$ff +lda {z1}+1 +sbc {z2}+1 +sta {z1}+1 +lda {z1}+2 +sbc {z2}+2 +sta {z1}+2 +lda {z1}+3 +sbc {z2}+3 +sta {z1}+3 +//FRAGMENT vbuaa=_byte_vduz1 +lda {z1} +//FRAGMENT vbuxx=_byte_vduz1 +lda {z1} tax -//FRAGMENT vbuyy=_bnot__deref_pbuc1 -lda {c1} -eor #$ff +//FRAGMENT vbuyy=_byte_vduz1 +lda {z1} tay -//FRAGMENT _deref_pbuc1=_deref_pbuc1_band_vbuaa -and {c1} -sta {c1} -//FRAGMENT _deref_pbuc1=_deref_pbuc1_band_vbuxx +//FRAGMENT vbuz1=vbuaa_rol_2 +asl +asl +sta {z1} +//FRAGMENT vbuz1=vbuxx_rol_2 txa -and {c1} -sta {c1} -//FRAGMENT _deref_pbuc1=_deref_pbuc1_band_vbuyy +asl +asl +sta {z1} +//FRAGMENT vbuz1=vbuyy_rol_2 tya -and {c1} -sta {c1} -//FRAGMENT pbuc1_derefidx_vbuz1=vbuaa -ldy {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=vbuaa -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuaa -sta {c1},y +asl +asl +sta {z1} +//FRAGMENT vbuaa=vbuz1_rol_2 +lda {z1} +asl +asl +//FRAGMENT vbuaa=vbuaa_rol_2 +asl +asl +//FRAGMENT vbuaa=vbuxx_rol_2 +txa +asl +asl +//FRAGMENT vbuaa=vbuyy_rol_2 +tya +asl +asl +//FRAGMENT vbuxx=vbuz1_rol_2 +lda {z1} +asl +asl +tax +//FRAGMENT vbuxx=vbuaa_rol_2 +asl +asl +tax +//FRAGMENT vbuxx=vbuxx_rol_2 +txa +asl +asl +tax +//FRAGMENT vbuxx=vbuyy_rol_2 +tya +asl +asl +tax +//FRAGMENT vbuyy=vbuz1_rol_2 +lda {z1} +asl +asl +tay +//FRAGMENT vbuyy=vbuaa_rol_2 +asl +asl +tay +//FRAGMENT vbuyy=vbuxx_rol_2 +txa +asl +asl +tay +//FRAGMENT vbuyy=vbuyy_rol_2 +tya +asl +asl +tay +//FRAGMENT vduz1=pduc1_derefidx_vbuaa +tay +lda {c1},y +sta {z1} +lda {c1}+1,y +sta {z1}+1 +lda {c1}+2,y +sta {z1}+2 +lda {c1}+3,y +sta {z1}+3 +//FRAGMENT vduz1=pduc1_derefidx_vbuxx +lda {c1},x +sta {z1} +lda {c1}+1,x +sta {z1}+1 +lda {c1}+2,x +sta {z1}+2 +lda {c1}+3,x +sta {z1}+3 +//FRAGMENT vduz1=pduc1_derefidx_vbuyy +lda {c1},y +sta {z1} +lda {c1}+1,y +sta {z1}+1 +lda {c1}+2,y +sta {z1}+2 +lda {c1}+3,y +sta {z1}+3 +//FRAGMENT _deref_pduc1=vbuc2 +NO_SYNTHESIS +//FRAGMENT _deref_pduc1=vbsc2 +NO_SYNTHESIS +//FRAGMENT _deref_pduc1=vwsc2 +NO_SYNTHESIS diff --git a/src/main/kc/include/veralib.h b/src/main/kc/include/veralib.h index 37aa8ec61..68feb8515 100644 --- a/src/main/kc/include/veralib.h +++ b/src/main/kc/include/veralib.h @@ -40,49 +40,49 @@ byte vera_layer_backcolor[2] = {BLUE, BLUE}; // Set the configuration of the layer. // - layer: Value of 0 or 1. // - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'. -void vera_layer_set_config(unsigned byte layer, unsigned byte config); +void vera_layer_set_config(byte layer, byte config); // Set the configuration of the layer. // - layer: Value of 0 or 1. // - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'. -unsigned byte vera_layer_get_config(unsigned byte layer); +byte vera_layer_get_config(byte layer); // Set the map width or height of the layer. // - layer: Value of 0 or 1. -inline void vera_layer_set_width_32(unsigned byte layer); -inline void vera_layer_set_width_64(unsigned byte layer); -inline void vera_layer_set_width_128(unsigned byte layer); -inline void vera_layer_set_width_256(unsigned byte layer); -inline void vera_layer_set_height_32(unsigned byte layer); -inline void vera_layer_set_height_64(unsigned byte layer); -inline void vera_layer_set_height_128(unsigned byte layer); -inline void vera_layer_set_height_256(unsigned byte layer); +inline void vera_layer_set_width_32(byte layer); +inline void vera_layer_set_width_64(byte layer); +inline void vera_layer_set_width_128(byte layer); +inline void vera_layer_set_width_256(byte layer); +inline void vera_layer_set_height_32(byte layer); +inline void vera_layer_set_height_64(byte layer); +inline void vera_layer_set_height_128(byte layer); +inline void vera_layer_set_height_256(byte layer); // Enable the layer to be displayed on the screen. // - layer: 0 or 1. -void vera_layer_show(unsigned byte layer); +void vera_layer_show(byte layer); // Disable the layer to be displayed on the screen. // - layer: 0 or 1. -void vera_layer_hide(unsigned byte layer); +void vera_layer_hide(byte layer); // Is the layer shown on the screen? // - returns: 1 if layer is displayed on the screen, 0 if not. -unsigned byte vera_layer_is_visible(unsigned byte layer); +byte vera_layer_is_visible(byte layer); // Set the base of the map for the layer with which the conio will interact. // - layer: Value of 0 or 1. // - mapbase: Specifies the base address of the tile map. // Note that the register only specifies bits 16:9 of the address, // so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes. -void vera_layer_set_mapbase(unsigned byte layer, unsigned byte mapbase); +void vera_layer_set_mapbase(byte layer, byte mapbase); // Get the base of the map for the layer with which the conio will interact. // - layer: Value of 0 or 1. // - return: Returns the base address of the tile map. // Note that the register is a byte, specifying only bits 16:9 of the address, // so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes! -unsigned byte vera_layer_get_mapbase(unsigned byte layer); +byte vera_layer_get_mapbase(byte layer); // Set the base of the map layer with which the conio will interact. // - layer: Value of 0 or 1. @@ -121,7 +121,7 @@ void vera_layer_set_tilebase_address(byte layer, dword tilebase_address); // - return: Specifies the base address of the tile map. // Note that the register only specifies bits 16:11 of the address, // so the resulting address in the VERA VRAM is always aligned to a multiple of 2048 bytes! -unsigned byte vera_layer_get_tilebase(unsigned byte layer); +byte vera_layer_get_tilebase(byte layer); // Set the front color for text output. The old front text color setting is returned. @@ -129,35 +129,35 @@ unsigned byte vera_layer_get_tilebase(unsigned byte layer); // - color: a 4 bit value ( decimal between 0 and 15). // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_set_textcolor(unsigned byte layer, unsigned byte color); +byte vera_layer_set_textcolor(byte layer, byte color); // Get the front color for text output. The old front text color setting is returned. // - layer: Value of 0 or 1. // - return: a 4 bit value ( decimal between 0 and 15). // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_get_textcolor(unsigned byte layer); +byte vera_layer_get_textcolor(byte layer); // Set the back color for text output. The old back text color setting is returned. // - layer: Value of 0 or 1. // - color: a 4 bit value ( decimal between 0 and 15). // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_set_backcolor(unsigned byte layer, unsigned byte color); +byte vera_layer_set_backcolor(byte layer, byte color); // Get the back color for text output. The old back text color setting is returned. // - layer: Value of 0 or 1. // - return: a 4 bit value ( decimal between 0 and 15). // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_get_backcolor(unsigned byte layer); +byte vera_layer_get_backcolor(byte layer); // Get the text and back color for text output in 16 color mode. // - layer: Value of 0 or 1. // - return: an 8 bit value with bit 7:4 containing the back color and bit 3:0 containing the front color. // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_get_color(unsigned byte layer); +byte vera_layer_get_color(byte layer); // Scroll the horizontal (X) axis of the layer visible area over the layer tile map area. // - layer: Value of 0 or 1. diff --git a/src/main/kc/lib/conio-cx16.c b/src/main/kc/lib/conio-cx16.c index e4fd185f2..204f2add2 100644 --- a/src/main/kc/lib/conio-cx16.c +++ b/src/main/kc/lib/conio-cx16.c @@ -71,7 +71,7 @@ void conio_x16_init() { // Position cursor at current line char * const BASIC_CURSOR_LINE = 0xD6; char line = *BASIC_CURSOR_LINE; - vera_layer_mode_tile(1,0x00000,0x0F800,128,64,8,8,1); + vera_layer_mode_tile(1,(dword)0x00000,(dword)0x0F800,128,64,8,8,1); screensize(&conio_screen_width, &conio_screen_height); screenlayer(1); vera_layer_set_textcolor(1, WHITE); diff --git a/src/main/kc/lib/veralib.c b/src/main/kc/lib/veralib.c index 579c607c0..4bae623c0 100644 --- a/src/main/kc/lib/veralib.c +++ b/src/main/kc/lib/veralib.c @@ -40,59 +40,59 @@ void vera_vram_address1(dword bankaddr, byte incr) { // Set the configuration of the layer. // - layer: Value of 0 or 1. // - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'. -void vera_layer_set_config(char layer, char config) { +void vera_layer_set_config(byte layer, byte config) { layer &= $1; - char* addr = vera_layer_config[layer]; + byte* addr = vera_layer_config[layer]; *addr = config; } // Set the configuration of the layer. // - layer: Value of 0 or 1. // - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'. -char vera_layer_get_config(char layer) { - char* config = vera_layer_config[layer]; +byte vera_layer_get_config(byte layer) { + byte* config = vera_layer_config[layer]; return *config; } // Set the map width or height of the layer. // - layer: Value of 0 or 1. -inline void vera_layer_set_width_32(unsigned byte layer) { +inline void vera_layer_set_width_32(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_WIDTH_MASK; *addr |= VERA_LAYER_WIDTH_32; } -inline void vera_layer_set_width_64(unsigned byte layer) { +inline void vera_layer_set_width_64(byte layer) { byte* addr = vera_layer_config[layer]; //*addr &= (~VERA_CONFIG_WIDTH_MASK) | VERA_CONFIG_WIDTH_64; *addr &= ~VERA_LAYER_WIDTH_MASK; *addr |= VERA_LAYER_WIDTH_64; } -inline void vera_layer_set_width_128(unsigned byte layer) { +inline void vera_layer_set_width_128(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_WIDTH_MASK; *addr |= VERA_LAYER_WIDTH_128; } -inline void vera_layer_set_width_256(unsigned byte layer) { +inline void vera_layer_set_width_256(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_WIDTH_MASK; *addr |= VERA_LAYER_WIDTH_256; } -inline void vera_layer_set_height_32(unsigned byte layer) { +inline void vera_layer_set_height_32(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_HEIGHT_MASK; *addr |= VERA_LAYER_HEIGHT_32; } -inline void vera_layer_set_height_64(unsigned byte layer) { +inline void vera_layer_set_height_64(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_HEIGHT_MASK; *addr |= VERA_LAYER_HEIGHT_64; } -inline void vera_layer_set_height_128(unsigned byte layer) { +inline void vera_layer_set_height_128(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_HEIGHT_MASK; *addr |= VERA_LAYER_HEIGHT_128; } -inline void vera_layer_set_height_256(unsigned byte layer) { +inline void vera_layer_set_height_256(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_HEIGHT_MASK; *addr |= VERA_LAYER_HEIGHT_256; @@ -100,13 +100,13 @@ inline void vera_layer_set_height_256(unsigned byte layer) { // Get the map width or height of the layer. // - layer: Value of 0 or 1. -word vera_layer_get_width(unsigned byte layer) { +word vera_layer_get_width(byte layer) { byte* config = vera_layer_config[layer]; byte mask = (byte)VERA_LAYER_WIDTH_MASK; return VERA_LAYER_WIDTH[ (*config & mask) >> 4]; } -word vera_layer_get_height(unsigned byte layer) { +word vera_layer_get_height(byte layer) { byte* config = vera_layer_config[layer]; byte mask = VERA_LAYER_HEIGHT_MASK; return VERA_LAYER_HEIGHT[ (*config & mask) >> 6]; @@ -114,22 +114,22 @@ word vera_layer_get_height(unsigned byte layer) { // Set the color depth of the layer in terms of bit per pixel (BPP) of the tile base. // - layer: Value of 0 or 1. -inline void vera_layer_set_color_depth_1BPP(unsigned byte layer) { +inline void vera_layer_set_color_depth_1BPP(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_COLOR_DEPTH_MASK; *addr |= VERA_LAYER_COLOR_DEPTH_1BPP; } -inline void vera_layer_set_color_depth_2BPP(unsigned byte layer) { +inline void vera_layer_set_color_depth_2BPP(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_COLOR_DEPTH_MASK; *addr |= VERA_LAYER_COLOR_DEPTH_2BPP; } -inline void vera_layer_set_color_depth_4BPP(unsigned byte layer) { +inline void vera_layer_set_color_depth_4BPP(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_COLOR_DEPTH_MASK; *addr |= VERA_LAYER_COLOR_DEPTH_4BPP; } -inline void vera_layer_set_color_depth_8BPP(unsigned byte layer) { +inline void vera_layer_set_color_depth_8BPP(byte layer) { byte* addr = vera_layer_config[layer]; *addr &= ~VERA_LAYER_COLOR_DEPTH_MASK; *addr |= VERA_LAYER_COLOR_DEPTH_8BPP; @@ -138,7 +138,7 @@ inline void vera_layer_set_color_depth_8BPP(unsigned byte layer) { // Get the map width or height of the layer. // - layer: Value of 0 or 1. // - return: 1, 2, 4 or 8. -word vera_layer_get_color_depth(unsigned byte layer) { +word vera_layer_get_color_depth(byte layer) { byte* config = vera_layer_config[layer]; byte mask = (byte)VERA_LAYER_COLOR_DEPTH_MASK; return VERA_LAYER_COLOR_DEPTH[(*config & mask)]; @@ -146,21 +146,21 @@ word vera_layer_get_color_depth(unsigned byte layer) { // Enable the layer to be displayed on the screen. // - layer: 0 or 1. -inline void vera_layer_show(char layer) { +inline void vera_layer_show(byte layer) { *VERA_DC_VIDEO |= vera_layer_enable[layer]; } // Disable the layer to be displayed on the screen. // - layer: 0 or 1. -inline void vera_layer_hide(char layer) { +inline void vera_layer_hide(byte layer) { *VERA_DC_VIDEO &= ~vera_layer_enable[layer]; } // Is the layer shown on the screen? // - returns: 1 if layer is displayed on the screen, 0 if not. -char vera_layer_is_visible(char layer) { +inline byte vera_layer_is_visible(byte layer) { return *VERA_DC_VIDEO & vera_layer_enable[layer]; } @@ -169,8 +169,8 @@ char vera_layer_is_visible(char layer) { // - mapbase: Specifies the base address of the tile map. // Note that the register only specifies bits 16:9 of the address, // so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes. -void vera_layer_set_mapbase(unsigned byte layer, unsigned byte mapbase) { - unsigned byte* addr = vera_layer_mapbase[layer]; +void vera_layer_set_mapbase(byte layer, byte mapbase) { + byte* addr = vera_layer_mapbase[layer]; *addr = mapbase; } @@ -223,8 +223,8 @@ word vera_layer_get_mapbase_offset(byte layer) { // - return: Returns the base address of the tile map. // Note that the register is a byte, specifying only bits 16:9 of the address, // so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes. -unsigned byte vera_layer_get_mapbase(unsigned byte layer) { - unsigned byte* mapbase = vera_layer_mapbase[layer]; +byte vera_layer_get_mapbase(byte layer) { + byte* mapbase = vera_layer_mapbase[layer]; return *mapbase; } @@ -233,8 +233,8 @@ unsigned byte vera_layer_get_mapbase(unsigned byte layer) { // - tilebase: Specifies the base address of the tile map. // Note that the register only specifies bits 16:11 of the address, // so the resulting address in the VERA VRAM is always aligned to a multiple of 2048 bytes! -void vera_layer_set_tilebase(unsigned byte layer, unsigned byte tilebase) { - unsigned byte* addr = vera_layer_tilebase[layer]; +void vera_layer_set_tilebase(byte layer, byte tilebase) { + byte* addr = vera_layer_tilebase[layer]; *addr = tilebase; } @@ -296,8 +296,8 @@ dword vera_layer_get_tilebase_address(byte layer) { // - color: a 4 bit value ( decimal between 0 and 15). // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_set_textcolor(unsigned byte layer, unsigned byte color) { - unsigned byte old = vera_layer_textcolor[layer]; +byte vera_layer_set_textcolor(byte layer, byte color) { + byte old = vera_layer_textcolor[layer]; vera_layer_textcolor[layer] = color; return old; } @@ -307,7 +307,7 @@ unsigned byte vera_layer_set_textcolor(unsigned byte layer, unsigned byte color) // - return: a 4 bit value ( decimal between 0 and 15). // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_get_textcolor(unsigned byte layer) { +byte vera_layer_get_textcolor(byte layer) { layer &= $1; return vera_layer_textcolor[layer]; } @@ -317,9 +317,9 @@ unsigned byte vera_layer_get_textcolor(unsigned byte layer) { // - color: a 4 bit value ( decimal between 0 and 15). // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_set_backcolor(unsigned byte layer, unsigned byte color) { +byte vera_layer_set_backcolor(byte layer, byte color) { layer &= $1; - unsigned byte old = vera_layer_backcolor[layer]; + byte old = vera_layer_backcolor[layer]; vera_layer_backcolor[layer] = color; return old; } @@ -329,7 +329,7 @@ unsigned byte vera_layer_set_backcolor(unsigned byte layer, unsigned byte color) // - return: a 4 bit value ( decimal between 0 and 15). // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_get_backcolor(unsigned byte layer) { +byte vera_layer_get_backcolor(byte layer) { layer &= $1; return vera_layer_backcolor[layer]; } @@ -339,7 +339,7 @@ unsigned byte vera_layer_get_backcolor(unsigned byte layer) { // - return: an 8 bit value with bit 7:4 containing the back color and bit 3:0 containing the front color. // This will only work when the VERA is in 16 color mode! // Note that on the VERA, the transparent color has value 0. -unsigned byte vera_layer_get_color(unsigned byte layer) { +byte vera_layer_get_color(byte layer) { layer &= $1; return ((vera_layer_backcolor[layer] << 4) | vera_layer_textcolor[layer]); } diff --git a/src/test/kc/examples/cx16/dword_low_hi.c b/src/test/kc/examples/cx16/dword_low_hi.c index 5aebed265..86ede233b 100644 --- a/src/test/kc/examples/cx16/dword_low_hi.c +++ b/src/test/kc/examples/cx16/dword_low_hi.c @@ -4,6 +4,7 @@ void main() { dword value = 0xff446677; +clrscr(); printf("77 = %x\n", <(<(value)) ); printf("66 = %x\n", >(<(value)) ); printf("44 = %x\n", <(>(value)) ); diff --git a/src/test/kc/examples/cx16/dword_word.c b/src/test/kc/examples/cx16/dword_word.c new file mode 100644 index 000000000..134930b6f --- /dev/null +++ b/src/test/kc/examples/cx16/dword_word.c @@ -0,0 +1,13 @@ + + +#include + +void main() { +word value = 0xf801; +dword dw_value[2] = {0,0}; +for(word t:0..1) { + dw_value[t] = 0xf800; +} +clrscr(); +printf("f801 = %x\n", dw_value[1] ); +} \ No newline at end of file diff --git a/src/test/kc/examples/cx16/tilemap.c b/src/test/kc/examples/cx16/tilemap.c index e8dc036ee..eb77d280c 100644 --- a/src/test/kc/examples/cx16/tilemap.c +++ b/src/test/kc/examples/cx16/tilemap.c @@ -19,15 +19,9 @@ void main() { bgcolor(BLACK); clrscr(); - // Now we set the tile map width and height. - // vera_layer_set_mapbase(0,0x80); // Set the map base to address 0x10000 in VERA VRAM! - // vera_layer_set_config(0, vera_layer_get_config(1)); - // vera_layer_set_tilebase(0, vera_layer_get_tilebase(1)); - // vera_layer_set_width_128(0); - // vera_layer_set_height_128(0); dword tilebase = vera_layer_get_tilebase_address(1); - vera_mode_tile(0, 0x10000, 0xF800, 128, 128, 8, 8, 1); + vera_layer_mode_tile(0, 0x10000, tilebase, 128, 128, 8, 8, 1); screenlayer(0); scroll(0); // Scrolling on conio is deactivated, so conio will output beyond the borders of the visible screen. diff --git a/src/test/kc/examples/cx16/tilemap_2bpp_8_x_8.c b/src/test/kc/examples/cx16/tilemap_2bpp_8_x_8.c index 4679ffe5e..fc9ec34a4 100644 --- a/src/test/kc/examples/cx16/tilemap_2bpp_8_x_8.c +++ b/src/test/kc/examples/cx16/tilemap_2bpp_8_x_8.c @@ -18,7 +18,7 @@ void main() { bgcolor(BLACK); clrscr(); - vera_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 2); + vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 2); byte tiles[64] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55, @@ -58,7 +58,7 @@ void main() { vera_layer_show(0); - gotoxy(0,40); + gotoxy(0,50); printf("vera in tile mode 8 x 8, color depth 2 bits per pixel.\n"); printf("in this mode, tiles are 8 pixels wide and 8 pixels tall.\n"); diff --git a/src/test/kc/examples/cx16/tilemap_4bpp_16_x_16.c b/src/test/kc/examples/cx16/tilemap_4bpp_16_x_16.c index b8bd6cc8a..9ffa32ae2 100644 --- a/src/test/kc/examples/cx16/tilemap_4bpp_16_x_16.c +++ b/src/test/kc/examples/cx16/tilemap_4bpp_16_x_16.c @@ -18,7 +18,7 @@ void main() { bgcolor(BLACK); clrscr(); - vera_mode_tile(0, 0x04000, 0x14000, 128, 128, 16, 16, 4); + vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 16, 16, 4); byte tiles[2048] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -207,7 +207,7 @@ void main() { vera_layer_show(0); - gotoxy(0,46); + gotoxy(0,50); printf("vera in tile mode 16 x 16, color depth 4 bits per pixel.\n"); printf("in this mode, tiles are 16 pixels wide and 16 pixels tall.\n"); diff --git a/src/test/kc/examples/cx16/tilemap_4bpp_8_x_8.c b/src/test/kc/examples/cx16/tilemap_4bpp_8_x_8.c index aba90d398..c48fb42c7 100644 --- a/src/test/kc/examples/cx16/tilemap_4bpp_8_x_8.c +++ b/src/test/kc/examples/cx16/tilemap_4bpp_8_x_8.c @@ -17,7 +17,7 @@ void main() { bgcolor(BLACK); clrscr(); - vera_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 4); + vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 4); byte tiles[512] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -56,8 +56,6 @@ void main() { memcpy_to_vram(1, 0x4000, tiles, 512); - //vera_tile_area(byte layer, word tileindex, byte x, byte y, byte w, byte h, byte hflip, byte vflip, byte offset) - vera_tile_area(0, 0, 0, 0, 80, 60, 0, 0, 0); word tile = 0; @@ -110,7 +108,7 @@ void main() { vera_layer_show(0); - gotoxy(0,46); + gotoxy(0,50); printf("vera in tile mode 8 x 8, color depth 4 bits per pixel.\n"); printf("in this mode, tiles are 8 pixels wide and 8 pixels tall.\n"); diff --git a/src/test/kc/examples/cx16/tilemap_8bpp_8_x_8.c b/src/test/kc/examples/cx16/tilemap_8bpp_8_x_8.c index 40b41a888..5ee9964dc 100644 --- a/src/test/kc/examples/cx16/tilemap_8bpp_8_x_8.c +++ b/src/test/kc/examples/cx16/tilemap_8bpp_8_x_8.c @@ -17,7 +17,7 @@ void main() { bgcolor(BLACK); clrscr(); - vera_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 8); + vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 8); byte tiles[64] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -75,7 +75,7 @@ void main() { vera_layer_show(0); - gotoxy(0,46); + gotoxy(0,50); printf("vera in tile mode 8 x 8, color depth 8 bits per pixel.\n"); printf("in this mode, tiles are 8 pixels wide and 8 pixels tall.\n");