mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-27 08:31:03 +00:00
refactor ALTZP switch to C
This commit is contained in:
parent
442fe390de
commit
a206fc06b8
@ -78,7 +78,7 @@ E(func) pushl %eax; \
|
|||||||
ret;
|
ret;
|
||||||
|
|
||||||
// TODO FIXME : implement CDECL prologue/epilogues...
|
// TODO FIXME : implement CDECL prologue/epilogues...
|
||||||
#define GLUE_C_READ(func) \
|
#define _GLUE_C_READ(func, ...) \
|
||||||
E(func) pushl XY_Regs_32; \
|
E(func) pushl XY_Regs_32; \
|
||||||
pushl FF_Reg; \
|
pushl FF_Reg; \
|
||||||
pushl SP_Reg; \
|
pushl SP_Reg; \
|
||||||
@ -90,5 +90,18 @@ E(func) pushl XY_Regs_32; \
|
|||||||
popl SP_Reg; \
|
popl SP_Reg; \
|
||||||
popl FF_Reg; \
|
popl FF_Reg; \
|
||||||
popl XY_Regs_32; \
|
popl XY_Regs_32; \
|
||||||
|
__VA_ARGS__ \
|
||||||
ret;
|
ret;
|
||||||
|
|
||||||
|
// TODO FIXME : implement CDECL prologue/epilogues...
|
||||||
|
#define GLUE_C_READ(FUNC) _GLUE_C_READ(FUNC)
|
||||||
|
|
||||||
|
#define GLUE_C_READ_ALTZP(FUNC) _GLUE_C_READ(FUNC, \
|
||||||
|
pushl %eax; \
|
||||||
|
andl $0xFFFF, SP_Reg; \
|
||||||
|
movl SN(base_stackzp), %eax; \
|
||||||
|
subl $SN(apple_ii_64k), %eax; \
|
||||||
|
orl %eax, SP_Reg; \
|
||||||
|
popl %eax; \
|
||||||
|
)
|
||||||
|
|
||||||
|
@ -152,53 +152,6 @@
|
|||||||
return80: movb $0x80,%al
|
return80: movb $0x80,%al
|
||||||
ret
|
ret
|
||||||
|
|
||||||
E(iie_altzp_main)
|
|
||||||
testl $SS_ALTZP, SN(softswitches)
|
|
||||||
jz 1f /* test if ALTZP already off -
|
|
||||||
* due to d000-bank issues it is
|
|
||||||
* *needed*, not just a shortcut */
|
|
||||||
andl $~SS_ALTZP, SN(softswitches)
|
|
||||||
movl $SN(apple_ii_64k), SN(base_stackzp)
|
|
||||||
andl $0xFFFF, SP_Reg
|
|
||||||
testl $SS_LCRAM|SS_LCWRT, SN(softswitches)
|
|
||||||
jz 1f /* shortest path for common case */
|
|
||||||
testl $SS_LCRAM, SN(softswitches)
|
|
||||||
jz 2f
|
|
||||||
subl $0x2000, SN(base_d000_rd)
|
|
||||||
movl $SN(language_card)-0xE000, SN(base_e000_rd)
|
|
||||||
2: testl $SS_LCWRT, SN(softswitches)
|
|
||||||
jz 1f
|
|
||||||
subl $0x2000, SN(base_d000_wrt)
|
|
||||||
movl $SN(language_card)-0xE000, SN(base_e000_wrt)
|
|
||||||
1: ret
|
|
||||||
|
|
||||||
E(iie_altzp_aux)
|
|
||||||
testl $SS_ALTZP, SN(softswitches)
|
|
||||||
jnz 1f /* test if ALTZP already on -
|
|
||||||
* due to d000-bank issues it is
|
|
||||||
* *needed*, not just a shortcut */
|
|
||||||
orl $SS_ALTZP, SN(softswitches)
|
|
||||||
movl $SN(apple_ii_64k)+BANK2, SN(base_stackzp)
|
|
||||||
orl $BANK2, SP_Reg
|
|
||||||
testl $SS_LCRAM|SS_LCWRT, SN(softswitches)
|
|
||||||
jz 1f /* shortest path for common case */
|
|
||||||
lc_to_auxmem: /* called by lc routines */
|
|
||||||
testl $SS_LCRAM, SN(softswitches)
|
|
||||||
jz 2f
|
|
||||||
addl $0x2000, SN(base_d000_rd)
|
|
||||||
movl $SN(language_card)-0xC000, SN(base_e000_rd)
|
|
||||||
2: testl $SS_LCWRT, SN(softswitches)
|
|
||||||
jz 1f
|
|
||||||
addl $0x2000, SN(base_d000_wrt)
|
|
||||||
movl $SN(language_card)-0xC000, SN(base_e000_wrt)
|
|
||||||
1: ret
|
|
||||||
|
|
||||||
E(iie_check_altzp)
|
|
||||||
testl $SS_ALTZP, SN(softswitches)
|
|
||||||
jnz return80
|
|
||||||
xorb %al, %al
|
|
||||||
ret
|
|
||||||
|
|
||||||
E(iie_80col_off)
|
E(iie_80col_off)
|
||||||
testl $SS_80COL, SN(softswitches)
|
testl $SS_80COL, SN(softswitches)
|
||||||
jz ram_nop
|
jz ram_nop
|
||||||
|
@ -29,3 +29,5 @@
|
|||||||
extern void func(); \
|
extern void func(); \
|
||||||
uint8_t c_##func(uint16_t ea) /* you complete definition */
|
uint8_t c_##func(uint16_t ea) /* you complete definition */
|
||||||
|
|
||||||
|
#define GLUE_C_READ_ALTZP(func, ...) GLUE_C_READ(func)
|
||||||
|
|
||||||
|
@ -3215,7 +3215,8 @@ GREATEST_SUITE(test_suite_vm) {
|
|||||||
GREATEST_SET_SETUP_CB(testvm_setup, NULL);
|
GREATEST_SET_SETUP_CB(testvm_setup, NULL);
|
||||||
GREATEST_SET_TEARDOWN_CB(testvm_teardown, NULL);
|
GREATEST_SET_TEARDOWN_CB(testvm_teardown, NULL);
|
||||||
|
|
||||||
c_read_random();
|
extern uint8_t c_read_random(uint16_t);
|
||||||
|
c_read_random(0x0);
|
||||||
srandom(0); // force a known sequence
|
srandom(0); // force a known sequence
|
||||||
|
|
||||||
test_common_init(/*cputhread*/true);
|
test_common_init(/*cputhread*/true);
|
||||||
|
43
src/vm.c
43
src/vm.c
@ -595,3 +595,46 @@ GLUE_C_READ(iie_check_ramwrt)
|
|||||||
return (softswitches & SS_RAMWRT) ? 0x80 : 0x00;
|
return (softswitches & SS_RAMWRT) ? 0x80 : 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLUE_C_READ_ALTZP(iie_altzp_main)
|
||||||
|
{
|
||||||
|
if (!(softswitches & SS_ALTZP)) {
|
||||||
|
/* NOTE : test if ALTZP already off - due to d000-bank issues it is *needed*, not just a shortcut */
|
||||||
|
return 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
softswitches &= ~SS_ALTZP;
|
||||||
|
base_stackzp = apple_ii_64k[0];
|
||||||
|
|
||||||
|
if (softswitches & SS_LCRAM) {
|
||||||
|
base_d000_rd -= 0x2000;
|
||||||
|
base_e000_rd = language_card[0] - 0xE000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (softswitches & SS_LCWRT) {
|
||||||
|
base_d000_wrt -= 0x2000;
|
||||||
|
base_e000_wrt = language_card[0] - 0xE000;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLUE_C_READ_ALTZP(iie_altzp_aux)
|
||||||
|
{
|
||||||
|
if (softswitches & SS_ALTZP) {
|
||||||
|
/* NOTE : test if ALTZP already on - due to d000-bank issues it is *needed*, not just a shortcut */
|
||||||
|
return 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
softswitches |= SS_ALTZP;
|
||||||
|
base_stackzp = apple_ii_64k[1];
|
||||||
|
|
||||||
|
_lc_to_auxmem();
|
||||||
|
|
||||||
|
return 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLUE_C_READ(iie_check_altzp)
|
||||||
|
{
|
||||||
|
return (softswitches & SS_ALTZP) ? 0x80 : 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user