Skip to content

Commit

Permalink
Merge pull request #55 from jbrandwood/master
Browse files Browse the repository at this point in the history
Add source-level-debugging .sym output for mesen2 to PCEAS and HuCC
  • Loading branch information
jbrandwood authored Nov 29, 2024
2 parents c6a852e + 1d37417 commit 0546b84
Show file tree
Hide file tree
Showing 51 changed files with 2,201 additions and 1,283 deletions.
20 changes: 20 additions & 0 deletions examples/asm/elmer/ipl-scd/ipl-scd.asm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@ iso_128mb = iso_dirhi ; index # of 1st beyond 128MB
.mlist



; ***************************************************************************
; ***************************************************************************
;
; "pcengine.inc" only defines these for a CD/SCD/ACD build so ...
;

.ifndef cd_read
cd_read = $00:E009, FUNC
ex_getver = $00:E05A, FUNC
ex_scrsiz = $00:E069, FUNC
ex_scrmod = $00:E06F, FUNC
ex_vsync = $00:E07B, FUNC
ex_bgon = $00:E08A, FUNC
ex_dspoff = $00:E099, FUNC
ex_memopen = $00:E0DE, FUNC
.endif



; ***************************************************************************
; ***************************************************************************
;
Expand Down
16 changes: 16 additions & 0 deletions examples/hucc/shmup/shmup.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
#incspr(explosion,"explosion.pcx",0,0,2,16)
#incpal(explosionpal,"explosion.pcx")

const unsigned char * aSpriteDataAddr[] = {
&bonk, &bullet, &ship, &explosion };

const unsigned char aSpriteDataBank[] = {
^bonk, ^bullet, ^ship, ^explosion };

#incchr(scene_chr,"scene.png")
#incpal(scene_pal,"scene.png")
#incbat(scene_bat,"scene.png",0x1000,32,28)
Expand Down Expand Up @@ -196,7 +202,17 @@ void main(void)
load_palette(18,shippal,1);
load_palette(19,explosionpal,1);

// you can either load vram using the label
sgx_load_vram(0x5000,bonk,0x400);

// or by using using the bank and address
set_far_base(aSpriteDataBank[0],aSpriteDataAddr[0]);
sgx_far_load_vram(0x5000,0x400);

// or by using using the bank and address with an offset
set_far_offset(0,aSpriteDataBank[0],aSpriteDataAddr[0]);
sgx_far_load_vram(0x5000,0x400);

sgx_load_vram(0x5400,bullet,0x40);
sgx_load_vram(0x5500,ship,0x400);
sgx_load_vram(0x5900,explosion,0x800);
Expand Down
32 changes: 31 additions & 1 deletion include/hucc/hucc-baselib.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;
; hucc-baselib.asm
;
; Basic library functions provided as macros.
; Basic library functions provided (mostly) as macros.
;
; Copyright John Brandwood 2024.
;
Expand Down Expand Up @@ -68,6 +68,36 @@ _exit.1: tax ; Put the return code into X.



; ***************************************************************************
; ***************************************************************************
;
; void __fastcall __xsafe __nop set_far_base( unsigned char data_bank<_bp_bank>, unsigned char *data_addr<_bp> );
; void __fastcall __xsafe set_far_offset( unsigned int offset<_bp>, unsigned char data_bank<_bp_bank>, unsigned char *data_addr<acc> );

_set_far_offset.3:
clc
adc.l <_bp
sta.l <_bp
tya
and #$1F
adc.h <_bp
tay
and #$1F
ora #$60
sta.h <_bp
tya
ror a
lsr a
lsr a
lsr a
lsr a
clc
adc <_bp_bank
sta <_bp_bank
rts



; ***************************************************************************
; ***************************************************************************
;
Expand Down
3 changes: 3 additions & 0 deletions include/hucc/hucc-baselib.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ extern unsigned char dh;

#asmdef HUCC_USES_BASELIB 1

extern void __fastcall __xsafe __nop set_far_base( unsigned char data_bank<_bp_bank>, unsigned char *data_addr<_bp> );
extern void __fastcall __xsafe set_far_offset( unsigned int offset<_bp>, unsigned char data_bank<_bp_bank>, unsigned char *data_addr<acc> );

extern unsigned char __fastcall __xsafe __macro sgx_detect( void );
extern unsigned char __fastcall __xsafe __macro ac_exists( void );

Expand Down
18 changes: 16 additions & 2 deletions include/hucc/hucc-codegen.asm
Original file line number Diff line number Diff line change
Expand Up @@ -520,16 +520,26 @@ __switch.ur .macro
jmp do_switchb
.endm

; **************
; the start of a "default" statement

__default .macro
plx
.endm

; **************
; the start of a "case" statement

__case .macro
plx
.endm

; **************
; the end of the previous "case" statement if it drops through
; turns next __case "plx" into an "ora"

__endcase .macro
db $09
.endm

; **************
Expand Down Expand Up @@ -4239,7 +4249,9 @@ smodw: sta.l <divisor

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

do_switchw: sty.h <__ptr ; Save hi-byte of the table address.
do_switchw: phx

sty.h <__ptr ; Save hi-byte of the table address.
sta.l <__temp ; Save lo-byte of the value to find.

lda [__ptr] ; Read #bytes of case values to check.
Expand Down Expand Up @@ -4276,7 +4288,9 @@ test_case_hi: lda.h <__temp ; Slow test loop for the hi-byte, which

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

do_switchb: sty.h <__ptr ; Save hi-byte of the table address.
do_switchb: phx

sty.h <__ptr ; Save hi-byte of the table address.
tay ; Save lo-byte of the value to find.

lda [__ptr] ; Read #bytes of case values to check.
Expand Down
100 changes: 50 additions & 50 deletions include/hucc/hucc-deprecated.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,66 +21,66 @@ HUC_USER_RESERVED = HUC_USER_BANK
; Code generated by HuCC uses the original single-underscore.

.if 1
__bp = $F8:20EC ; base pointer
__si = $F8:20EE ; source address
__di = $F8:20F0 ; destination address
__bp = $F8:20EC, 2 ; base pointer
__si = $F8:20EE, 2 ; source address
__di = $F8:20F0, 2 ; destination address

__ax = $F8:20F8
__al = $F8:20F8
__ah = $F8:20F9
__ax = $F8:20F8, 2
__al = $F8:20F8, 1
__ah = $F8:20F9, 1

__bx = $F8:20FA
__bl = $F8:20FA
__bh = $F8:20FB
__bx = $F8:20FA, 2
__bl = $F8:20FA, 1
__bh = $F8:20FB, 1

__cx = $F8:20FC
__cl = $F8:20FC
__ch = $F8:20FD
__cx = $F8:20FC, 2
__cl = $F8:20FC, 1
__ch = $F8:20FD, 1

__dx = $F8:20FE
__dl = $F8:20FE
__dh = $F8:20FF
__dx = $F8:20FE, 2
__dl = $F8:20FE, 1
__dh = $F8:20FF, 1
.endif

; For compatibility with code that expects the HuC naming that
; is used rather than the shorter upper-case #define naming.

.if 1
video_reg = $FF:0200 ; Address/Status Register
video_reg_l = $FF:0200 ; Address/Status Register
video_reg_h = $FF:0201 ; Address/Status Register
video_data = $FF:0202 ; Data (Read/Write) Low
video_data_l = $FF:0202 ; Data (Read/Write) Low
video_data_h = $FF:0203 ; Data (Read/Write) High

color_ctrl = $FF:0400 ; Control Register
color_reg = $FF:0402 ; Color Table Address
color_reg_l = $FF:0402 ; Color Table Address
color_reg_h = $FF:0402 ; Color Table Address
color_data = $FF:0404 ; Color Table Data Read/Write
color_data_l = $FF:0404 ; Color Table Data Read/Write
color_data_h = $FF:0405 ; Color Table Data Read/Write

psg_ch = $FF:0800 ; Channel Select
psg_mainvol = $FF:0801 ; Main Amplitude Level
psg_freqlo = $FF:0802 ; Frequency Low
psg_freqhi = $FF:0803 ; Frequency High
psg_ctrl = $FF:0804 ; Control & Channel Amplitude
psg_pan = $FF:0805 ; L/R Amplitude Level
psg_wavebuf = $FF:0806 ; Waveform
psg_noise = $FF:0807 ; Noise
psg_lfofreq = $FF:0808 ; LFO Frequency
psg_lfoctrl = $FF:0809 ; LFO Control

irq_m = irq_vec ; Old System Card name.
irq2_jmp = irq2_hook ; Old System Card name.
irq1_jmp = irq1_hook ; Old System Card name.
timer_jmp = timer_hook ; Old System Card name.
nmi_jmp = nmi_hook ; Old System Card name.
sat_adr = satb_addr ; Old System Card name.
joy = joynow ; Old System Card name.
mwr_m = vdc_mwr ; Old System Card name.
dcr_m = vdc_dcr ; Old System Card name.
video_reg = $FF:0200, 1 ; Address/Status Register
video_reg_l = $FF:0200, 1 ; Address/Status Register
video_reg_h = $FF:0201, 1 ; Address/Status Register
video_data = $FF:0202, 2 ; Data (Read/Write) Low
video_data_l = $FF:0202, 1 ; Data (Read/Write) Low
video_data_h = $FF:0203, 1 ; Data (Read/Write) High

color_ctrl = $FF:0400, 2 ; Control Register
color_reg = $FF:0402, 2 ; Color Table Address
color_reg_l = $FF:0402, 1 ; Color Table Address
color_reg_h = $FF:0402, 1 ; Color Table Address
color_data = $FF:0404, 2 ; Color Table Data Read/Write
color_data_l = $FF:0404, 1 ; Color Table Data Read/Write
color_data_h = $FF:0405, 1 ; Color Table Data Read/Write

psg_ch = $FF:0800, 1 ; Channel Select
psg_mainvol = $FF:0801, 1 ; Main Amplitude Level
psg_freqlo = $FF:0802, 1 ; Frequency Low
psg_freqhi = $FF:0803, 1 ; Frequency High
psg_ctrl = $FF:0804, 1 ; Control & Channel Amplitude
psg_pan = $FF:0805, 1 ; L/R Amplitude Level
psg_wavebuf = $FF:0806, 1 ; Waveform
psg_noise = $FF:0807, 1 ; Noise
psg_lfofreq = $FF:0808, 1 ; LFO Frequency
psg_lfoctrl = $FF:0809, 1 ; LFO Control

irq_m = irq_vec, 1 ; Old System Card name.
irq2_jmp = irq2_hook, 2 ; Old System Card name.
irq1_jmp = irq1_hook, 2 ; Old System Card name.
timer_jmp = timer_hook, 2 ; Old System Card name.
nmi_jmp = nmi_hook, 2 ; Old System Card name.
sat_adr = satb_addr, 2 ; Old System Card name.
joy = joynow, 5 ; Old System Card name.
mwr_m = vdc_mwr, 1 ; Old System Card name.
dcr_m = vdc_dcr, 1 ; Old System Card name.
.endif

; Macros for compatibility with #asm usage in old HuC projects.
Expand Down
Loading

0 comments on commit 0546b84

Please sign in to comment.