Skip to content

Commit

Permalink
Merge pull request #63 from jbrandwood/master
Browse files Browse the repository at this point in the history
Bug fixes and more optimization.
  • Loading branch information
jbrandwood authored Dec 19, 2024
2 parents ea76f73 + 64fec7a commit fbfc888
Show file tree
Hide file tree
Showing 16 changed files with 787 additions and 468 deletions.
24 changes: 6 additions & 18 deletions include/hucc/hucc-baselib.asm
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,9 @@ _vsync.1 .macro

_joy.1 .macro
.if SUPPORT_6BUTTON
tay
lda joy6now, y
pha
lda joynow, y
ply
tax
lda joynow, x
ldy joy6now, x
.else
tay
lda joynow, y
Expand All @@ -292,11 +290,9 @@ _joy.1 .macro

_joytrg.1 .macro
.if SUPPORT_6BUTTON
tay
lda joy6trg, y
pha
lda joytrg, y
ply
tax
lda joytrg, x
ldy joy6trg, x
.else
tay
lda joytrg, y
Expand Down Expand Up @@ -531,37 +527,29 @@ _set_xres.1 .macro
; void __fastcall __macro sgx_put_vram( unsigned int address<_di>, unsigned int data<acc> );

.macro _get_vram.1
phx
jsr vdc_di_to_marr
plx
lda VDC_DL
ldy VDC_DH
.endm

.macro _put_vram.2
pha
phx
jsr vdc_di_to_mawr
plx
pla
sta VDC_DL
sty VDC_DH
.endm

.if SUPPORT_SGX
.macro _sgx_get_vram.1
phx
jsr sgx_di_to_marr
plx
lda SGX_DL
ldy SGX_DH
.endm

.macro _sgx_put_vram.2
pha
phx
jsr sgx_di_to_mawr
plx
pla
sta SGX_DL
sty SGX_DH
Expand Down
292 changes: 292 additions & 0 deletions include/hucc/hucc-codegen.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,147 @@ __uge_w.wm .macro
sbc.h \1 ; CS if Y:A >= memory.
.endm

; **************
; optimized boolean test
; C is true (1) if Y:A == memory-value, else false (0)
; this MUST set the C flag for the subsequent branches!

__equ_w.um .macro
cmp \1
bne !false+
tya
beq !+
!false: clc
!:
.endm

; **************
; optimized boolean test
; C is true (1) if Y:A != memory-value, else false (0)
; this MUST set the C flag for the subsequent branches!

__neq_w.um .macro
sec
eor \1
bne !+
tya
bne !+
clc
!:
.endm

; **************
; optimized boolean test (signed word)
; C is true (1) if Y:A < memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__slt_w.um .macro
cmp \1 ; Subtract memory from Y:A.
tya
sbc #0
bvc !+
eor #$80 ; -ve if Y:A < memory (signed).
!: asl a
.endm

; **************
; optimized boolean test (signed word)
; C is true (1) if Y:A <= memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__sle_w.um .macro
clc ; Subtract memory+1 from Y:A.
sbc \1
tya
sbc #0
bvc !+
eor #$80 ; -ve if Y:A <= memory (signed).
!: asl a
.endm

; **************
; optimized boolean test (signed word)
; C is true (1) if Y:A > memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__sgt_w.um .macro
clc ; Subtract memory+1 from Y:A.
sbc \1
tya
sbc #0
bvc !+
eor #$80 ; +ve if Y:A > memory (signed).
!: eor #$80
asl a
.endm

; **************
; optimized boolean test (signed word)
; C is true (1) if Y:A >= memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__sge_w.um .macro
cmp \1 ; Subtract memory from Y:A.
tya
sbc #0
bvc !+
eor #$80 ; +ve if Y:A >= memory (signed).
!: eor #$80
asl a
.endm

; **************
; optimized boolean test (unsigned word)
; C is true (1) if Y:A < memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__ult_w.um .macro
cmp \1 ; Subtract memory from Y:A.
tya
sbc #0 ; CC if Y:A < memory.
ror a
eor #$80
rol a
.endm

; **************
; optimized boolean test (unsigned word)
; C is true (1) if Y:A <= memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__ule_w.um .macro
clc ; Subtract memory+1 from Y:A.
sbc \1
tya
sbc #0 ; CC if Y:A <= memory.
ror a
eor #$80
rol a
.endm

; **************
; optimized boolean test (unsigned word)
; C is true (1) if Y:A > memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__ugt_w.um .macro
clc ; Subtract memory+1 from Y:A.
sbc \1
tya
sbc #0 ; CS if Y:A > memory.
.endm

; **************
; optimized boolean test (unsigned word)
; C is true (1) if Y:A >= memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__uge_w.um .macro
cmp \1 ; Subtract memory from Y:A.
tya
sbc #0 ; CS if Y:A >= memory.
.endm

; **************
; optimized boolean test
; C is true (1) if A == memory-value, else false (0)
Expand Down Expand Up @@ -1394,6 +1535,157 @@ __uge_w.ws .macro
sbc.h <__stack + \1, x; CS if Y:A >= memory.
.endm

; **************
; optimized boolean test
; C is true (1) if Y:A == memory-value, else false (0)
; this MUST set the C flag for the subsequent branches!

__equ_w.us .macro
ldx.l <__sp
cmp <__stack + \1, x
bne !false+
tya
beq !+
!false: clc
!:
.endm

; **************
; optimized boolean test
; C is true (1) if Y:A != memory-value, else false (0)
; this MUST set the C flag for the subsequent branches!

__neq_w.us .macro
ldx.l <__sp
sec
eor <__stack + \1, x
bne !+
tya
bne !+
clc
!:
.endm

; **************
; optimized boolean test (signed word)
; C is true (1) if Y:A < memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__slt_w.us .macro
ldx.l <__sp
cmp <__stack + \1, x; Subtract memory from Y:A.
tya
sbc #0
bvc !+
eor #$80 ; -ve if Y:A < memory (signed).
!: asl a
.endm

; **************
; optimized boolean test (signed word)
; C is true (1) if Y:A <= memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__sle_w.us .macro
ldx.l <__sp
clc ; Subtract memory+1 from Y:A.
sbc <__stack + \1, x
tya
sbc #0
bvc !+
eor #$80 ; -ve if Y:A <= memory (signed).
!: asl a
.endm

; **************
; optimized boolean test (signed word)
; C is true (1) if Y:A > memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__sgt_w.us .macro
ldx.l <__sp
clc ; Subtract memory+1 from Y:A.
sbc <__stack + \1, x
tya
sbc #0
bvc !+
eor #$80 ; +ve if Y:A > memory (signed).
!: eor #$80
asl a
.endm

; **************
; optimized boolean test (signed word)
; C is true (1) if Y:A >= memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__sge_w.us .macro
ldx.l <__sp
cmp <__stack + \1, x; Subtract memory from Y:A.
tya
sbc #0
bvc !+
eor #$80 ; +ve if Y:A >= memory (signed).
!: eor #$80
asl a
.endm

; **************
; optimized boolean test (unsigned word)
; C is true (1) if Y:A < memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__ult_w.us .macro
ldx.l <__sp
cmp <__stack + \1, x; Subtract memory from Y:A.
tya
sbc #0 ; CC if Y:A < memory.
ror a
eor #$80
rol a
.endm

; **************
; optimized boolean test (unsigned word)
; C is true (1) if Y:A <= memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__ule_w.us .macro
ldx.l <__sp
clc ; Subtract memory+1 from Y:A.
sbc <__stack + \1, x
tya
sbc #0 ; CC if Y:A <= memory.
ror a
eor #$80
rol a
.endm

; **************
; optimized boolean test (unsigned word)
; C is true (1) if Y:A > memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__ugt_w.us .macro
ldx.l <__sp
clc ; Subtract memory+1 from Y:A.
sbc <__stack + \1, x
tya
sbc #0 ; CS if Y:A > memory.
.endm

; **************
; optimized boolean test (unsigned word)
; C is true (1) if Y:A >= memory-value, else false (0)
; this MUST set the C flag for the susequent branches!

__uge_w.us .macro
ldx.l <__sp
cmp <__stack + \1, x; Subtract memory from Y:A.
tya
sbc #0 ; CS if Y:A >= memory.
.endm

; **************
; optimized boolean test
; C is true (1) if A == memory-value, else false (0)
Expand Down
Loading

0 comments on commit fbfc888

Please sign in to comment.