Skip to content

Commit

Permalink
Merge pull request #78 from jbrandwood/master
Browse files Browse the repository at this point in the history
Add load_sprites() to HuCC.
  • Loading branch information
jbrandwood authored Feb 26, 2025
2 parents e4ba39b + 2db9d3b commit 5b0619a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 11 deletions.
6 changes: 6 additions & 0 deletions include/hucc/core-startup.asm
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ __trampolineptr = $5FFF ; are in MPR2, tell PCEAS to

CORE_BANK = bank(*) - _bank_base ; It isn't always zero! ;-)

.bank CORE_BANK, "CORE_BANK" ; Give it a label.

.if USING_MPR7
CORE_PAGE = 7 ; User code runs in MPR7.
.else
Expand Down Expand Up @@ -600,7 +602,11 @@ CONST_BANK .rs 2

DATA_BANK .rs 0
.data
.if BUILDING_STAGE1
.bank DATA_BANK
.else
.bank DATA_BANK, ".data"
.endif
.org $6000

.code
42 changes: 42 additions & 0 deletions include/hucc/hucc-baselib.asm
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,48 @@ _set_sprpal.3 .macro



; ***************************************************************************
; ***************************************************************************
;
; N.B. Declared in hucc-gfx.h, but defined here because they're macros!
;
; void __fastcall __macro load_sprites( unsigned int vram<_di>, unsigned char __far *data<_bp_bank:_bp>, unsigned int num_groups<acc> );
; void __fastcall __macro sgx_load_sprites( unsigned int vram<_di>, unsigned char __far *data<_bp_bank:_bp>, unsigned int num_groups<acc> );
; void __fastcall __macro far_load_sprites( unsigned int vram<_di>, unsigned int num_groups<acc> );
; void __fastcall __macro sgx_far_load_sprites( unsigned int vram<_di>, unsigned int num_groups<acc> );

.if SUPPORT_SGX
.macro _sgx_load_sprites.3
stz.l <_ax
asl a
sta.h <_ax
call _sgx_load_vram.3
.endm

.macro _sgx_far_load_sprites.2
stz.l <_ax
asl a
sta.h <_ax
call _sgx_load_vram.3
.endm
.endif

.macro _load_sprites.3
stz.l <_ax
asl a
sta.h <_ax
call _load_vram.3
.endm

.macro _far_load_sprites.2
stz.l <_ax
asl a
sta.h <_ax
call _load_vram.3
.endm



; ***************************************************************************
; ***************************************************************************

Expand Down
22 changes: 11 additions & 11 deletions include/hucc/hucc-codegen.asm
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,11 @@ __switch_r.wr .macro
jmp [!table+, x]
.endm

; !table: dw jmp1 ; +01 x=\1
; dw jmp2 ; +23 x=\1+1
; dw jmp3 ; +45 x=\1+2
; dw jmp4 ; +67 x=\2
; dw jmpdefault ; +89 x=\2+1
; !table: dw jmp1 ; +01 x=(\1 - \1)
; dw jmp2 ; +23 x=(\1 - \1)+1
; dw jmp3 ; +45 x=(\1 - \1)+2
; dw jmp4 ; +67 x=(\2 - \1)
; dw jmpdefault ; +89 x=(\2 - \1)+1

; **************
; Y:A is the value to check for.
Expand All @@ -561,7 +561,7 @@ __switch_r.ur .macro
.endif
.else
sec
sbc.l #\1
sbc #\1
bvc !+
eor #$80
!: bmi !default+
Expand All @@ -574,11 +574,11 @@ __switch_r.ur .macro
jmp [!table+, x]
.endm

; !table: dw jmp1 ; +01 x=\1
; dw jmp2 ; +23 x=\1+1
; dw jmp3 ; +45 x=\1+2
; dw jmp4 ; +67 x=\2
; dw jmpdefault ; +89 x=\2+1
; !table: dw jmp1 ; +01 x=(\1 - \1)
; dw jmp2 ; +23 x=(\1 - \1)+1
; dw jmp3 ; +45 x=(\1 - \1)+2
; dw jmp4 ; +67 x=(\2 - \1)
; dw jmpdefault ; +89 x=(\2 - \1)+1

; **************
; the start of a "default" statement
Expand Down
6 changes: 6 additions & 0 deletions include/hucc/hucc-gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ extern void __fastcall sgx_load_bat( unsigned int vram<_di>, unsigned char __far

extern void __fastcall load_palette( unsigned char palette<_al>, unsigned char __far *data<_bp_bank:_bp>, unsigned char num_palettes<_ah> );

extern void __fastcall __macro load_sprites( unsigned int vram<_di>, unsigned char __far *data<_bp_bank:_bp>, unsigned int num_groups<acc> );
extern void __fastcall __macro sgx_load_sprites( unsigned int vram<_di>, unsigned char __far *data<_bp_bank:_bp>, unsigned int num_groups<acc> );

extern void __fastcall set_font_addr( unsigned int vram<acc> );
extern void __fastcall set_font_pal( unsigned char palette<acc> );

Expand Down Expand Up @@ -131,6 +134,9 @@ extern void __fastcall sgx_far_load_bat( unsigned int vram<_di>, unsigned char t
extern void __fastcall far_load_palette( unsigned char palette<_al>, unsigned char num_palettes<_ah> );
extern void __fastcall far_load_font( unsigned char count<_al>, unsigned int vram<acc> );

extern void __fastcall __macro far_load_sprites( unsigned int vram<_di>, unsigned int num_groups<acc> );
extern void __fastcall __macro sgx_far_load_sprites( unsigned int vram<_di>, unsigned int num_groups<acc> );

// Deprecated functions ...

extern void __fastcall load_background( unsigned char __far *tiles<_bp_bank:_bp>, unsigned char __far *palettes<__fbank:__fptr>, unsigned char __far *bat<_cl:_bx>, unsigned char w<_dl>, unsigned char h<_dh> );
Expand Down

0 comments on commit 5b0619a

Please sign in to comment.