1
0
mirror of https://github.com/KarolS/millfork.git synced 2026-04-19 10:42:10 +00:00

Allow importing modules from subdirectories. Move platform definitions

This commit is contained in:
Karol Stasiak
2020-04-27 12:40:49 +02:00
parent c8492173ee
commit 78fe0e37bb
60 changed files with 115 additions and 23 deletions
@@ -6,7 +6,7 @@
#pragma zilog_syntax
import i80_math
import i80/i80_math
macro asm void poke(word const addr, byte register(a) value) {
! LD (addr), A
+27
View File
@@ -0,0 +1,27 @@
import random
#if not(ARCH_6809)
#warn random_6809 module should be only used on 6809-compatible targets
#endif
asm byte rand() {
? lda #8
? ldb rand_seed+0
__rand_loop:
aslb
? rolb rand_seed+1
bcc __no_eor
eorb #$2D
__no_eor:
deca
bne __rand_loop
? sta rand_seed+0
? rts
}
inline void init_rand_seed() {
// TODO: find a better source of randomness
rand_seed = 1
}
+51
View File
@@ -0,0 +1,51 @@
// target-independent things
#if not(ARCH_6809)
#warn stdlib_6809 module should be only used on 6809-compatible targets
#endif
word nmi_routine_addr @$FFFC
word reset_routine_addr @$FFFE
word irq_routine_addr @$FFF8
word swi_routine_addr @$FFFA
word firq_routine_addr @$FFF6
word swi2_routine_addr @$FFF4
word swi3_routine_addr @$FFF2
macro asm void poke(word const addr, byte register(b) value) {
! STB addr
}
macro asm byte peek(word const addr) {
! LDB addr
}
macro asm void disable_irq() {
ORCC #$30
}
macro asm void enable_irq() {
ANDCC #$CF
}
asm byte hi_nibble_to_hex(byte register(a) value) {
LSRB
LSRB
LSRB
LSRB
? JMP lo_nibble_to_hex
}
asm byte lo_nibble_to_hex(byte register(a) value) {
! ANDB #$F
ADDB #$30
CMPB #$3A
BCC _lo_nibble_to_hex_lbl
ADDB #$7 // carry is set
_lo_nibble_to_hex_lbl:
? RTS
}
macro asm void panic() {
? JSR _panic
}
+5 -3
View File
@@ -2,12 +2,14 @@
word rand_seed
#if ARCH_6502
import random_6502
import m6502/random_6502
#elseif ARCH_I80
import random_i80
import i80/random_i80
#elseif ARCH_X86
#warn 8086 is a partially supported architecture
import random_i80
import m6502/random_i80
#elseif ARCH_6809
import m6809/random_6809
#else
#warn Unsupported architecture
#endif
+2 -2
View File
@@ -12,9 +12,9 @@ alias scrstrzappend = strzappend
#else
#if ARCH_I80
import scrstring_fastpointers
import internal/scrstring_fastpointers
#else
import scrstring_fastindices
import internal/scrstring_fastindices
#endif
void scrstrzappend(pointer buffer, pointer str) {
+5 -3
View File
@@ -1,12 +1,14 @@
// target-independent things
#if ARCH_6502
import stdlib_6502
import m6502/stdlib_6502
#elseif ARCH_I80
import stdlib_i80
import i80/stdlib_i80
#elseif ARCH_X86
#warn 8086 is a partially supported architecture
import stdlib_i80
import i80/stdlib_i80
#elseif ARCH_6809
import m6809/stdlib_6809
#endif
#if PAL && NTSC
+2 -2
View File
@@ -1,9 +1,9 @@
import err
#if ARCH_I80
import string_fastpointers
import internal/string_fastpointers
#else
import string_fastindices
import internal/string_fastindices
#endif
void strzappend(pointer buffer, pointer str) {