2018-07-12 16:30:35 +00:00
|
|
|
// target-independent things
|
|
|
|
|
2018-07-30 16:16:50 +00:00
|
|
|
#if not(ARCH_I80)
|
|
|
|
#warn stdlib_i80 module should be only used on Intel 8080-like targets
|
2018-07-12 16:30:35 +00:00
|
|
|
#endif
|
|
|
|
|
2018-08-03 11:23:37 +00:00
|
|
|
#pragma zilog_syntax
|
|
|
|
|
2018-09-28 21:45:26 +00:00
|
|
|
import i80_math
|
|
|
|
|
2020-03-30 17:23:48 +00:00
|
|
|
macro asm void poke(word const addr, byte register(a) value) {
|
2018-12-16 20:07:04 +00:00
|
|
|
! LD (addr), A
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro asm byte peek(word const addr) {
|
2018-12-16 20:07:04 +00:00
|
|
|
! LD A, (addr)
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro asm void disable_irq() {
|
|
|
|
DI
|
|
|
|
}
|
|
|
|
|
|
|
|
macro asm void enable_irq() {
|
|
|
|
EI
|
|
|
|
}
|
|
|
|
|
2020-03-30 17:23:48 +00:00
|
|
|
asm byte hi_nibble_to_hex(byte register(a) value) {
|
2018-07-30 16:16:50 +00:00
|
|
|
#if CPUFEATURE_GAMEBOY
|
|
|
|
SWAP A
|
|
|
|
#else
|
2018-08-01 08:16:20 +00:00
|
|
|
RRA
|
|
|
|
RRA
|
|
|
|
RRA
|
|
|
|
RRA
|
2018-07-30 16:16:50 +00:00
|
|
|
#endif
|
2018-08-01 08:16:20 +00:00
|
|
|
? JP lo_nibble_to_hex
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 17:23:48 +00:00
|
|
|
asm byte lo_nibble_to_hex(byte register(a) value) {
|
2018-07-12 16:30:35 +00:00
|
|
|
AND $F
|
|
|
|
ADD A,$30
|
|
|
|
CP $3A
|
2018-07-30 16:16:50 +00:00
|
|
|
#if CPUFEATURE_GAMEBOY | CPUFEATURE_Z80
|
2018-07-12 16:30:35 +00:00
|
|
|
JR C,_lo_nibble_to_hex_lbl
|
2018-07-30 16:16:50 +00:00
|
|
|
#else
|
|
|
|
JP C,_lo_nibble_to_hex_lbl
|
|
|
|
#endif
|
2018-07-24 17:11:40 +00:00
|
|
|
ADD A,$7
|
2018-07-12 16:30:35 +00:00
|
|
|
_lo_nibble_to_hex_lbl:
|
|
|
|
RET
|
|
|
|
}
|
|
|
|
|
|
|
|
macro asm void panic() {
|
2018-12-16 20:07:04 +00:00
|
|
|
? CALL _panic
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
2019-07-26 22:58:10 +00:00
|
|
|
|
|
|
|
noinline asm word call(word de) {
|
|
|
|
PUSH DE
|
|
|
|
RET
|
|
|
|
}
|