.nolist
#include "tse.inc"
.list
.org    usermem-3
.db     $BB,$6D
 ret
.db "TSE",1              ; header
prgtitle:
.db " Crash Protector", 0 ; title
.dw 100
start:
 im 1
 ld hl,int_start
 ld bc,int_end-int_start
 ld de,$9898
 ldir
 ld hl,$9A00
 ld a,h
 ld i,a
 ld a,$98
 ld bc,257
 bcall(_memset)
 im 2
 call _tseForceYield
int_start:
 ex af,af'
 exx
 di
 ld a,0ffh
 out (1),a
 ld a,Group1
 out (1),a
 in a,(1)
 cp kLeft & kRight
 jp nz,skip
 ld a,0ffh
 out (1),a
 ld a,Group7
 out (1),a
 in a,(1)
 cp k2nd
 jr nz,skip
 bcall(_clrlcdfull)
 ld hl,0000h
 ld (pencol),hl
 ld hl,label1-usermem+$9898
 bcall(_vputs)
 ld hl,0700h
 ld (pencol),hl
 ld hl,label2-usermem+$9898
 bcall(_vputs)
 ld hl,1e00h
 ld (pencol),hl
 ld hl,label3-usermem+$9898
 bcall(_vputs)
Crashloop:
 ld a,0ffh
 out (1),a
 ld a,Group7
 out (1),a
 cp k2nd
 jr nz,Crashloop
crashloop2:
 call _tseForceYield
 jr crashloop2
label1:
 .db "Crash Protector v1.0",0
label2:
 .db "By Michael Vincent",0
label3:
 .db "Press 2nd to return to TSE",0
skip:
 ei
 exx
 ex af,af'
 jp $3A
int_end:
.end

