Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

127 lines (88 sloc) 1.889 kb
:device_lem1802
.dat 0
:device_clock
.dat 0
:video_ram_address
.dat 0x4000
:clock_interrupt_msg
.dat 0xcccc
:clock_tick_counter
.dat 0
:msg_lem1802_initialized
.dat "LEM1802 initialized, video ram set to 0x4000!", 0xA, 0
:msg_clock_initialized
.dat "generic_clock initialized", 0xA, 0
:msg_clock_five_seconds
.dat "Five seconds have passed", 0xA, 0
.globl startup
:startup
; Set the interrupt handler
IAS interrupt_handler
; Find the lem1802 device
SET A, 0xf615
SET B, 0x7349
JSR func_is_hardware_present
IFN X, 1
SET PC, error
SET [device_lem1802], Y
; Set the video RAM address
SET A, 0
SET B, [video_ram_address]
HWI [device_lem1802]
; Clear the screen
SET A, [video_ram_address]
SET B, 3
JSR func_lem1802_clear_screen
; Print a message to show that the screen is working
SET A, [video_ram_address]
SET B, msg_lem1802_initialized
SET C, 0
SET X, 0x10
JSR func_lem1802_prints
; Find the clock device
SET A, 0xb402
SET B, 0x12d0
JSR func_is_hardware_present
IFN X, 1
SET PC, error
SET [device_clock], Y
; Set the clock speed (1 tick per second)
SET A, 0
SET B, 60
HWI [device_clock]
; Enable clock interrupts
SET A, 2
SET B, [clock_interrupt_msg]
HWI [device_clock]
; Tell user that clock is running
SET A, [video_ram_address]
SET B, msg_clock_initialized
SET C, 0
SET X, 0x10
JSR func_lem1802_prints
:end_loop
SET PC, end_loop
:interrupt_handler
JSR func_pusha
IFE A, [clock_interrupt_msg]
JSR clock_interrupt
JSR func_popa
RFI 0
:clock_interrupt
JSR func_pusha
ADD [clock_tick_counter], 1
IFL [clock_tick_counter], 5
SET PC, clock_interrupt_done
SET [clock_tick_counter], 0
SET A, [video_ram_address]
SET B, msg_clock_five_seconds
SET C, 0xC
SET X, 0x10
JSR func_lem1802_prints
:clock_interrupt_done
JSR func_popa
SET PC, POP
:error
; BREAKPOINT
.dat 0x0018
SET PC, end_loop
Jump to Line
Something went wrong with that request. Please try again.