First commit
This commit is contained in:
8
src/bios.s
Normal file
8
src/bios.s
Normal file
@@ -0,0 +1,8 @@
|
||||
__bios_call::
|
||||
ld hl, (1)
|
||||
add l
|
||||
ld l, a
|
||||
jp nc, bios_call_cont
|
||||
inc h
|
||||
bios_call_cont:
|
||||
jp (hl)
|
||||
29
src/console.c
Normal file
29
src/console.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "console.h"
|
||||
|
||||
char get_char() __naked {
|
||||
__asm
|
||||
ld a, #6
|
||||
call __bios_call
|
||||
ld l, a
|
||||
ret
|
||||
__endasm;
|
||||
}
|
||||
|
||||
void put_char(char c) __naked {
|
||||
c;
|
||||
__asm
|
||||
ld iy, #2
|
||||
add iy, sp
|
||||
ld c, 0(iy)
|
||||
ld a, #9
|
||||
call __bios_call
|
||||
ret
|
||||
__endasm;
|
||||
}
|
||||
|
||||
void put_string(char* s) {
|
||||
while (*s) {
|
||||
put_char(*s);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
52
src/crt0.s
Normal file
52
src/crt0.s
Normal file
@@ -0,0 +1,52 @@
|
||||
;--------------------------------------------------------------------------
|
||||
; cpm0.s - Generic cpm0.s for a Z80 CP/M-80 v2.2 Application
|
||||
; Copyright (C) 2011, Douglas Goodall All Rights Reserved.
|
||||
;--------------------------------------------------------------------------
|
||||
|
||||
.area _CODE
|
||||
.ds 0x0100
|
||||
init:
|
||||
;; Define an adequate stack
|
||||
ld sp, #stktop
|
||||
|
||||
;; Initialise global variables
|
||||
call gsinit
|
||||
|
||||
;; Call the C main routine
|
||||
call _main
|
||||
|
||||
;; Return back to CP/M
|
||||
ld c, #0
|
||||
call 5
|
||||
|
||||
;; Ordering of segments for the linker.
|
||||
.area _TPA
|
||||
|
||||
.area _HOME
|
||||
.area _CODE
|
||||
.area _INITIALIZER
|
||||
.area _GSINIT
|
||||
.area _GSFINAL
|
||||
.area _DATA
|
||||
.area _INITIALIZED
|
||||
|
||||
.area _STACK
|
||||
.ds 256
|
||||
stktop:
|
||||
|
||||
.area _GSINIT
|
||||
gsinit::
|
||||
ld bc, #l__INITIALIZER
|
||||
ld a, b
|
||||
or a, c
|
||||
jr z, gsinit_next
|
||||
ld de, #s__INITIALIZED
|
||||
ld hl, #s__INITIALIZER
|
||||
ldir
|
||||
gsinit_next:
|
||||
.area _GSFINAL
|
||||
ret
|
||||
|
||||
;;;;;;;;;;;;;;;;
|
||||
; eof - cpm0.s ;
|
||||
;;;;;;;;;;;;;;;;
|
||||
29
src/random.s
Normal file
29
src/random.s
Normal file
@@ -0,0 +1,29 @@
|
||||
; Fast RND
|
||||
;
|
||||
; An 8-bit pseudo-random number generator,
|
||||
; using a similar method to the Spectrum ROM,
|
||||
; - without the overhead of the Spectrum ROM.
|
||||
;
|
||||
; R = random number seed
|
||||
; an integer in the range [1, 256]
|
||||
;
|
||||
; R -> (33*R) mod 257
|
||||
;
|
||||
; S = R - 1
|
||||
; an 8-bit unsigned integer
|
||||
|
||||
_random::
|
||||
ld a, (_seed)
|
||||
ld b, a
|
||||
|
||||
rrca ; multiply by 32
|
||||
rrca
|
||||
rrca
|
||||
xor #0x1f
|
||||
|
||||
add a, b
|
||||
sbc a, #255 ; carry
|
||||
|
||||
ld (_seed), a
|
||||
ld l, a
|
||||
ret
|
||||
Reference in New Issue
Block a user