2020-11-01 13:06:01 +01:00
|
|
|
jp Sysinit ; Startup vector: DO NOT MOVE! Must be the first instruction
|
|
|
|
|
2020-10-27 20:08:07 +01:00
|
|
|
; Pat80 BIOS v0.01
|
|
|
|
; @author: Daniele Verducci
|
2020-11-24 21:34:51 +01:00
|
|
|
;
|
2020-11-01 12:25:51 +01:00
|
|
|
; MEMORY MAP
|
|
|
|
; ROM is at 0x0000
|
|
|
|
; RAM is at 0x8000
|
|
|
|
; SYSTEM VAR SPACE: 0x8000 - 0x8FFF (4kb)
|
|
|
|
; DRIVERS VAR SPACE: 0x9000 - 0x9FFF (4kb)
|
|
|
|
; APPLICATION VAR SPACE: 0xA000 - 0xFFFF (24kb)
|
|
|
|
; I/O MAP
|
2021-02-03 21:31:13 +01:00
|
|
|
; I/O 0 (0x00 - 0x1F) Parallel terminal (uses addr 0x00 and 0x01)
|
2020-12-06 15:51:26 +01:00
|
|
|
; I/O 1 (0x20 - 0x3F) Sound card (uses addr 0x20 only)
|
2021-02-03 21:31:13 +01:00
|
|
|
; I/O 2 (0x40 - 0x5F) PS2 Keyboard (uses 0x40 and 0x41)
|
2020-11-01 12:25:51 +01:00
|
|
|
; I/O 3 (0x60 - 0x7F)
|
|
|
|
; I/O 4 (0x80 - 0x9F)
|
|
|
|
; I/O 5 (0xA0 - 0xBF)
|
|
|
|
; I/O 6 (0xC0 - 0xDF)
|
|
|
|
; I/O 7 (0xE0 - 0xFF)
|
|
|
|
|
2021-01-02 10:53:30 +01:00
|
|
|
; **** RESET/INTERRUPT VECTOR ****
|
|
|
|
|
2021-01-03 09:37:22 +01:00
|
|
|
; Maskable interrupt mode 1: when the BREAK key is pressed,
|
|
|
|
; a maskable interrupt is generated and the CPU jumps to this address.
|
|
|
|
; In this way, BREAK key brings up memory monitor at any time.
|
2021-01-02 10:53:30 +01:00
|
|
|
ds 0x38
|
2021-01-03 09:37:22 +01:00
|
|
|
di ; Disable maskable interrupts.
|
|
|
|
exx ; exchange registers
|
|
|
|
ex af, af'
|
|
|
|
jp Monitor_main
|
2021-01-02 10:53:30 +01:00
|
|
|
|
2020-12-29 23:28:30 +01:00
|
|
|
; **** SYSTEM CALLS ****
|
|
|
|
; System calls provide access to low level functions (input from keyboard, output to screen etc).
|
|
|
|
; The name starts always with Sys_
|
2021-01-02 10:53:30 +01:00
|
|
|
ds 0x40 ; Place system calls after Z80 reset/interrupt subroutines space
|
2020-12-29 23:28:30 +01:00
|
|
|
|
2020-12-30 19:58:32 +01:00
|
|
|
; Returns ABI version.
|
|
|
|
; (ABI -> https://en.wikipedia.org/wiki/Application_binary_interface)
|
|
|
|
; Any Pat80 application should check the ABI version on startup, and refuse to run if not compatible.
|
|
|
|
; @return bc the ABI version
|
|
|
|
Sys_ABI:
|
|
|
|
ld bc, 0
|
|
|
|
ret
|
|
|
|
|
2020-12-29 23:28:30 +01:00
|
|
|
; Prints string
|
|
|
|
; @param BC Pointer to a null-terminated string first character
|
|
|
|
Sys_Print:
|
2020-12-30 19:58:32 +01:00
|
|
|
jp Term_print
|
2020-12-29 23:28:30 +01:00
|
|
|
|
|
|
|
; Writes a single character
|
|
|
|
; @param A Value of character to print
|
|
|
|
Sys_Printc:
|
2020-12-30 19:58:32 +01:00
|
|
|
jp Term_printc
|
2020-12-29 23:28:30 +01:00
|
|
|
|
|
|
|
; Reads a single character
|
|
|
|
; @return A The read character
|
|
|
|
Sys_Readc:
|
2021-02-03 21:31:13 +01:00
|
|
|
;jp Term_readc
|
|
|
|
jp PS2Keyb_readc
|
2020-12-29 23:28:30 +01:00
|
|
|
|
|
|
|
; Reads a line
|
|
|
|
; @return BC The pointer to a null-terminated read string
|
|
|
|
Sys_Readline:
|
2020-12-30 19:58:32 +01:00
|
|
|
jp Term_readline
|
2020-12-29 23:28:30 +01:00
|
|
|
|
|
|
|
; Emits system beep
|
|
|
|
Sys_Beep:
|
2020-12-30 19:58:32 +01:00
|
|
|
jp Snd_beep
|
2020-12-29 23:28:30 +01:00
|
|
|
|
|
|
|
|
2020-11-01 12:25:51 +01:00
|
|
|
|
2020-11-01 13:06:01 +01:00
|
|
|
; MEMORY CONFIGURATION
|
|
|
|
SYS_VAR_SPACE: EQU 0x8000
|
|
|
|
DRV_VAR_SPACE: EQU 0x9000
|
2020-11-25 21:07:46 +01:00
|
|
|
APP_SPACE: EQU 0xA000
|
2020-10-27 20:08:07 +01:00
|
|
|
|
|
|
|
; SYSTEM CONFIGURATION
|
2020-11-01 12:25:51 +01:00
|
|
|
IO_0: EQU 0x00
|
|
|
|
IO_1: EQU 0x20
|
|
|
|
IO_2: EQU 0x40
|
|
|
|
IO_3: EQU 0x60
|
|
|
|
IO_4: EQU 0x80
|
|
|
|
IO_5: EQU 0xA0
|
|
|
|
IO_6: EQU 0xC0
|
|
|
|
IO_7: EQU 0xE0
|
|
|
|
|
2020-10-27 20:08:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-25 19:39:20 +01:00
|
|
|
;include 'drivers/hd44780.asm'
|
|
|
|
;include 'drivers/keyboard.asm'
|
2021-02-03 21:31:13 +01:00
|
|
|
include 'drivers/ps2_keyboard.asm'
|
2020-12-06 15:51:26 +01:00
|
|
|
include 'drivers/arduino_terminal.asm'
|
2020-12-05 12:45:18 +01:00
|
|
|
include 'drivers/sn76489.asm'
|
2020-12-06 15:51:26 +01:00
|
|
|
include 'monitor.asm'
|
2020-12-05 12:45:18 +01:00
|
|
|
include 'libs/time.asm'
|
2020-12-06 15:51:26 +01:00
|
|
|
;include 'tests/sndtest.asm'
|
2020-12-05 12:45:18 +01:00
|
|
|
|
2020-10-27 20:08:07 +01:00
|
|
|
|
2020-12-06 15:51:26 +01:00
|
|
|
; **** SYSTEM INITIALIZATION ****
|
|
|
|
Sysinit:
|
|
|
|
; Init snd driver
|
2020-12-05 12:45:18 +01:00
|
|
|
call Snd_init
|
2020-12-06 15:51:26 +01:00
|
|
|
|
|
|
|
; Init video
|
|
|
|
; TODO
|
|
|
|
|
|
|
|
; Wait for audio amp to unmute
|
|
|
|
ld bc, TIME_DUR_SECOND
|
2020-12-05 12:45:18 +01:00
|
|
|
call Time_delay55
|
2020-12-06 15:51:26 +01:00
|
|
|
|
|
|
|
; Play startup sound
|
2020-12-29 23:28:30 +01:00
|
|
|
call Sys_Beep
|
2020-12-06 15:51:26 +01:00
|
|
|
|
2021-01-02 10:53:30 +01:00
|
|
|
; Run memory monitor
|
|
|
|
ei ; enable maskabpe interrupts
|
|
|
|
im 1 ; set interrupt mode 1 (on interrupt jumps to 0x38)
|
|
|
|
rst 0x38 ; throw fake interrupt: jump to interrupt routine to start monitor
|
2020-12-06 15:51:26 +01:00
|
|
|
|
2021-01-02 10:53:30 +01:00
|
|
|
; User exited from memory monitor without loading a program. Do nothing.
|
|
|
|
mloop:
|
|
|
|
; Main loop: do nothing.
|
|
|
|
jp mloop
|
2020-12-06 15:51:26 +01:00
|
|
|
|
2021-01-02 16:33:51 +01:00
|
|
|
; DEBUG: Echo chars
|
|
|
|
; loop:
|
|
|
|
; call Term_readc
|
|
|
|
; call Term_printc
|
|
|
|
; jp loop
|