
;;; gcc for m6809 : Mar 27 2025 02:43:37
;;; 4.6.4 (gcc6809lw pl9)
;;; ABI version 1
;;; -mint16
	.module	_nekot1.c

	.area	.text
_Reset64:
	ldd	#0
	std	_root64
	rts
_PutRawByte:
	pshs	y,u
	ldx	_Console
	stb	,x+
	stx	_Console
	bra	L3
L6:
	ldu	#544
L4:
	leay	32,u
	ldd	,y
	std	,u++
	cmpu	#960	;cmphi:
	bne	L4
L5:
	ldy	#8224
	sty	,u++
	cmpu	#992	;cmphi:
	bne	L5
	leax	-32,x
L3:
	cmpx	#991	;cmphi:
	bhi	L6
	stx	_Console
	ldb	#-1
	stb	,x
	puls	y,u,pc
_PutChar:
	leas	-1,s
L19:
	stb	,s
	ldb	#32
	stb	[_Console]
	ldb	,s
	cmpb	#10	;cmpqi:
	beq	L17
	bra	L21
L12:
	jsr	_PutChar
L17:
	ldx	_Console
	ldb	#32
	cmpx	#990	;cmphi:
	bhi	L19
	bra	L12
L21:
	ldb	,s
	cmpb	#31	;cmpqi:
	bls	L9
	cmpb	#95	;cmpqi:
	bhi	L15
	andb	#63
	stb	,s
	bra	L20
L15:
	ldb	,s
	bmi	L16
	addb	#-96
	bra	L20
L16:
	ldb	,s
L20:
	leas	1,s
	jmp	_PutRawByte
L9:
	leas	1,s
	rts
_PutStr:
	pshs	u
	leau	,x
	bra	L23
L24:
	jsr	_PutChar
L23:
	ldb	,u+
	bne	L24
	puls	u,pc
_PutHex:
	pshs	u
	leas	-4,s
	leau	,x
	cmpx	#15	;cmphi:
	bls	L26
	tfr	x,d
	lsra
	rorb
	lsra
	rorb
	lsra
	rorb
	lsra
	rorb
	std	2,s
	tfr	d,x
	jsr	_PutHex
L26:
	tfr	u,d
	anda	#0
	andb	#15
	tfr	d,x
	ldb	_HexAlphabet,x
	leas	4,s
	puls	u
	jmp	_PutChar
_DivMod10:
	ldd	#0
	bra	L28
L29:
	leax	-10000,x
	addd	#1000
L28:
	cmpx	#9999	;cmphi:
	bhi	L29
	bra	L36
L31:
	leax	-1000,x
	addd	#100
L36:
	cmpx	#999	;cmphi:
	bhi	L31
	bra	L37
L33:
	leax	-100,x
	addd	#10
L37:
	cmpx	#99	;cmphi:
	bhi	L33
	bra	L38
L35:
	leax	-10,x
	addd	#1
L38:
	cmpx	#9	;cmphi:
	bhi	L35
	std	[2,s]
	tfr	x,d	;movlsbqihi: R:x -> R:b
	rts
_PutDec:
	pshs	y,u
	leas	-2,s
	leau	,s
	leay	,x
	cmpx	#9	;cmphi:
	bls	L40
	ldd	#0
	pshs	u	;addhi: R:d += R:u
	addd	,s++
	pshs	d
	jsr	_DivMod10
	ldx	,u
	jsr	_PutDec
	leas	2,s
L40:
	ldd	#0
	pshs	u	;addhi: R:d += R:u
	addd	,s++
	pshs	d
	leax	,y
	jsr	_DivMod10
	addb	#48
	jsr	_PutChar
	leas	4,s
	puls	y,u,pc
_Irq_Handler_Wrapper:
;----- asm -----
;  67 "nekot1/irq.c" 1
	
  .globl _Irq_Handler_entry  
_Irq_Handler_entry:  
  JSR _Irq_Handler  
  RTI  

;--- end asm ---
	ldx	#_Irq_Handler
	stx	0
	rts
_gIrqSaveAndDisable:
	leas	-1,s
;----- asm -----
;  132 "nekot1/kern.c" 1
	
  tfr cc,b  
  stb ,s  
  orcc #$10  

;--- end asm ---
	ldb	,s
	leas	1,s
	rts
_gIrqRestore:
	leas	-1,s
	stb	,s
;----- asm -----
;  144 "nekot1/kern.c" 1
	
  ldb ,s  
  tfr b,cc  

;--- end asm ---
	leas	1,s
	rts
_gFree64:
	pshs	u
	leau	,x
	cmpx	#0	;cmphi:
	beq	L44
	jsr	_gIrqSaveAndDisable
	ldx	_root64
	stx	2,u
	ldx	#7905
	stx	,u
	stu	_root64
	puls	u
	jmp	_gIrqRestore
L44:
	puls	u,pc
_xAfterSetup:
	pshs	y,u
	leas	-2,s
	stx	,s
	ldy	10,s
	ldu	8,s
	leax	2,u
	bra	L47
L48:
	ldb	#63
	stb	,x+
L47:
	pshs	x	;cmphi: R:x with R:y
	cmpy	,s++	;cmphi:
	bhi	L48
;----- asm -----
;  159 "nekot1/kern.c" 1
	
  ldx   ,s           
  lds   #$01FE       
  pshs  X            
LOOP_FOREVER:        
  ldx   ,S           
  jsr   ,X           
  bra  LOOP_FOREVER  

;--- end asm ---
	leas	2,s
	puls	y,u,pc
_ClearPage256:
	pshs	y,u
	ldy	#0
L50:
	tfr	y,d
	leau	d,x
	ldd	#0
	std	,u
	leay	2,y
	cmpy	#256	;cmphi:
	bne	L50
	puls	y,u,pc
_entry_wrapper:
;----- asm -----
;  40 "nekot1/main.c" 1
	
  .globl entry 
entry:         
  orcc #$50    
  lds #$01FE   
  jmp _main    

;--- end asm ---
	rts
_gReceiveCast64:
	pshs	u
	jsr	_gIrqSaveAndDisable
	ldu	_recvcast_root
	beq	L54
	ldx	62,u
	stx	_recvcast_root
L54:
	jsr	_gIrqRestore
	ldd	#0
	std	62,u
	leax	,u
	puls	u,pc
_gMemcpy:
	pshs	y,u
	leas	-2,s
	ldu	8,s
	ldd	10,s
	anda	#0
	andb	#1
	tfr	d,y
	cmpy	#0	;cmphi:
	beq	L56
	ldb	,u+
	stb	,x+
L56:
	ldd	10,s
	lsra
	rorb
	std	,s
	ldy	#0
	bra	L57
L58:
	ldd	,u++
	std	,x++
	leay	1,y
L57:
	cmpy	,s	;cmphi:
	bne	L58
	leas	2,s
	puls	y,u,pc
_SendPartialScores:
	ldx	#_SendPartialScores
	stx	0
	rts
_NowSwitchDisplayMode:
	pshs	y,u
	leas	-9,s
	stb	2,s
	ldb	15,s
	stb	5,s
	ldb	2,s
	andb	#248
	stb	2,s
	stx	,s
	jsr	_gIrqSaveAndDisable
	stb	8,s
	ldb	2,s
	stb	_Vdg+4
	stb	-222
	ldy	#-58
	ldd	#512
	std	2,s
	ldx	,s
L62:
	ldd	2,s
	pshs	x
	anda	,s+
	andb	,s+
	std	6,s
	nega
	negb
	sbca	#0
	tfr	d,u
	ldd	6,s
	pshs	u
	ora	,s+
	orb	,s+
	tfr	a,b
	clra		;zero_extendqihi: R:b -> R:d
	rolb
	rolb
	andb	#1
	leau	d,y
	clr	,u
	asl	3,s
	rol	2,s
	leay	2,y
	cmpy	#-44	;cmphi:
	bne	L62
	ldb	5,s
	andb	#1
	stb	2,s
	clra		;zero_extendqihi: R:b -> R:d
	tfr	d,u
	leax	-64,u
	clr	,x
	ldb	5,s
	lsra
	rorb
	anda	#0
	andb	#1
	tfr	d,u
	leax	-62,u
	clr	,x
	ldb	5,s
	lsra
	rorb
	lsra
	rorb
	anda	#0
	andb	#1
	tfr	d,u
	leax	-60,u
	clr	,x
	ldb	8,s
	leas	9,s
	puls	y,u
	jmp	_gIrqRestore
_NowSwitchToGameScreen:
	ldd	_Vdg
	tfr	a,b
	clra		;zero_extendqihi: R:b -> R:d
	tfr	d,x
	ldb	_Vdg+1	;movlsbqihi: msb:_Vdg -> R:b
	pshs	b
	tfr	x,d	;movlsbqihi: R:x -> R:b
	ldx	_Vdg+2
	jsr	_NowSwitchDisplayMode
	leas	1,s
	rts
_gTextScreen:
	tstb	;cmpqi:(ZERO)
	beq	L68
	ldd	#2048
	bra	L66
L68:
	ldd	#0
L66:
	std	_Vdg
	stx	_Vdg+2
	ldb	_gKern+4
	beq	L65
	jsr	_NowSwitchToGameScreen
L65:
	rts
_StartTask:
	pshs	u
	leas	-2,s
	stx	,s
;----- asm -----
;  73 "nekot1/kern.c" 1
	  orcc #$10
;--- end asm ---
	cmpx	#0	;cmphi:
	bne	L70
	ldx	#_ChatTask
	stx	,s
L70:
	ldx	#128
L71:
	ldd	#0
	std	,x++
	cmpx	#256	;cmphi:
	bne	L71
	ldx	,s
	cmpx	#_ChatTask	;cmphi:
	beq	L72
	ldu	#16191
	stu	0
	stu	2
	stu	4
	stu	6
	ldu	#15360
	bra	L73
L72:
	ldx	#__Final
	bra	L74
L75:
	ldd	#0
	std	,x
L74:
	leax	2,x
	cmpx	#14335	;cmphi:
	bls	L75
	ldx	#8192
L76:
	ldu	#16191
	stu	,x++
	cmpx	#16384	;cmphi:
	bne	L76
	clr	_gKern+6
	clr	_gKern+4
	bra	L77
L73:
	ldx	#16191
	stx	,u
	tfr	u,d
	anda	#7
	andb	#255
	cmpd	#0	;cmphi:
	bne	L78
	ldb	#95
	jsr	_PutChar
L78:
	leau	2,u
	cmpu	#-274	;cmphi:
	bne	L73
	ldb	#1
	stb	_gKern+6
	stb	_gKern+4
	ldx	#512
	jsr	_gTextScreen
L77:
	clr	_gKern+7
;----- asm -----
;  119 "nekot1/kern.c" 1
	
  ldx   ,s      
  lds   #$01FE  
  andcc #^$50   
  jmp   ,X      

;--- end asm ---
	leas	2,s
	puls	u,pc
_embark:
	pshs	u
	ldx	#__Final+2
	bra	L83
L84:
	ldu	#16191
	stu	,x++
L83:
	cmpx	__Final_Startup	;cmphi:
	blo	L84
	ldx	#_ChatTask
	puls	u
	jmp	_StartTask
_gPMode1Screen:
	pshs	u
	ldu	#-16380
	tstb	;cmpqi:(ZERO)
	beq	L86
	ldu	#-14332
L86:
	stu	_Vdg
	stx	_Vdg+2
	ldb	_gKern+4
	beq	L85
	jsr	_NowSwitchToGameScreen
L85:
	puls	u,pc
_gModeScreen:
	pshs	u
	ldu	4,s
	stu	_Vdg
	stx	_Vdg+2
	ldb	_gKern+4
	beq	L89
	jsr	_NowSwitchToGameScreen
L89:
	puls	u,pc
_NowSwitchToChatScreen:
	ldb	_gKern+6
	beq	L93
	ldb	#8
	bra	L92
L93:
	clrb
L92:
	clr	,-s
	ldx	#512
	jsr	_NowSwitchDisplayMode
	leas	1,s
	rts
LC1:
	.ascii "\nFATAL \0"
LC2:
	.ascii ": \0"
LC3:
	.ascii "\n$\0"
_gFatal:
	pshs	y,u
	leas	-4,s
	stx	2,s
;----- asm -----
;  17 "nekot1/kern.c" 1
	  orcc #$10
;--- end asm ---
	jsr	_NowSwitchToChatScreen
	ldx	#LC1
	jsr	_PutStr
	ldx	10,s
	jsr	_PutDec
	ldx	#LC2
	jsr	_PutStr
	leau	4,s
	ldx	,--u
	jsr	_PutStr
	ldx	#LC3
	jsr	_PutStr
	ldx	#_gFatal
	stx	0
	stu	0
	leax	10,s
	stx	2
	ldy	4
	leax	,y
	jsr	_PutHex
	ldx	#LC2
	jsr	_PutStr
	ldu	#0
L97:
	tfr	u,d
	leax	d,y
	ldb	,x
	clra		;zero_extendqihi: R:b -> R:d
	std	,s
	tfr	d,x
	jsr	_PutHex
	tfr	u,d
	anda	#0
	andb	#3
	cmpd	#3	;cmphi:
	bne	L95
	ldb	#44
	jsr	_PutChar
L95:
	tfr	u,d
	anda	#0
	andb	#15
	cmpd	#15	;cmphi:
	bne	L96
	ldb	#59
	jsr	_PutChar
L96:
	ldb	#32
	jsr	_PutChar
	leau	1,u
	cmpu	#32	;cmphi:
	bne	L97
	ldb	#36
	jsr	_PutChar
	bra	L98
L99:
	ldx	512
	leax	1,x
	stx	512
L98:
	ldb	_gKern+5
	bne	L99
	leas	4,s
	puls	y,u,pc
LC4:
	.ascii "FIRQ\0"
_gFatalFIRQ:
;----- asm -----
;  61 "nekot1/kern.c" 1
	sts _SavedStackPointer
;--- end asm ---
	ldd	#55
	std	,--s
	ldx	#LC4
	jsr	_gFatal
	leas	2,s
	rts
LC5:
	.ascii "NMI\0"
_gFatalNMI:
;----- asm -----
;  57 "nekot1/kern.c" 1
	sts _SavedStackPointer
;--- end asm ---
	ldd	#44
	std	,--s
	ldx	#LC5
	jsr	_gFatal
	leas	2,s
	rts
LC6:
	.ascii "SWI\0"
_gFatalSWI3:
;----- asm -----
;  53 "nekot1/kern.c" 1
	sts _SavedStackPointer
;--- end asm ---
	ldd	#33
	std	,--s
	ldx	#LC6
	jsr	_gFatal
	leas	2,s
	rts
_gFatalSWI2:
;----- asm -----
;  49 "nekot1/kern.c" 1
	sts _SavedStackPointer
;--- end asm ---
	ldd	#22
	std	,--s
	ldx	#LC6
	jsr	_gFatal
	leas	2,s
	rts
_gFatalSWI1:
;----- asm -----
;  45 "nekot1/kern.c" 1
	sts _SavedStackPointer
;--- end asm ---
	ldd	#11
	std	,--s
	ldx	#LC6
	jsr	_gFatal
	leas	2,s
	rts
LC7:
	.ascii "BONOBO\0"
_bSendControl:
	stb	-152
	ldx	#-9981
L108:
	ldb	-152
	cmpb	#98	;cmpqi:
	beq	L106
	leax	-1,x
	cmpx	#0	;cmphi:
	bne	L108
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC7
	jsr	_gFatal
	leas	2,s
L106:
	rts
LC8:
	.ascii "nekot1/bonobo.c\0"
_BonoboSend:
	pshs	y,u
	leas	-1,s
	leay	,x
	ldu	7,s
	jsr	_gIrqSaveAndDisable
	stb	,s
	cmpu	#0	;cmphi:
	bne	L111
	ldd	#86
	std	,--s
	ldx	#LC8
	jsr	_gFatal
	ldd	#59
	bra	L115
L111:
	cmpu	#100	;cmphi:
	bls	L112
	ldd	#87
	std	,--s
	ldx	#LC8
	jsr	_gFatal
	ldd	#60
L115:
	std	,--s
	ldx	#LC8
	jsr	_gFatal
	leas	4,s
L112:
	tfr	u,d	;movlsbqihi: R:u -> R:b
	addb	#100
	jsr	_bSendControl
	leax	,y
	ldy	#0
	bra	L113
L114:
	ldb	,x+
	stb	-150
	leay	1,y
L113:
	pshs	u	;cmphi: R:u with R:y
	cmpy	,s++	;cmphi:
	bne	L114
	ldb	#-5
	jsr	_bSendControl
	ldb	,s
	leas	1,s
	puls	y,u
	jmp	_gIrqRestore
_SendPacket:
	pshs	y,u
	leas	-7,s
	stb	1,s
	leau	,x
	jsr	_gIrqSaveAndDisable
	stb	,s
	ldb	1,s
	stb	2,s
	ldb	15,s
	clra		;zero_extendqihi: R:b -> R:d
	tfr	d,y
	std	3,s
	stu	5,s
	ldd	#5
	std	,--s
	leax	4,s
	jsr	_BonoboSend
	pshs	y
	ldx	17,s
	jsr	_BonoboSend
	ldb	4,s
	jsr	_gIrqRestore
	leas	11,s
	puls	y,u,pc
_xSendControlPacket:
	ldb	5,s
	stb	4,s
	ldb	#70
	jmp	_SendPacket
LC9:
	.ascii "nekot1/network.c\0"
_gSendCast:
	pshs	u
	leas	-3,s
	leau	,x
	stb	,s
	cmpb	#60	;cmpqi:
	bls	L119
	ldd	#20
	std	,--s
	ldx	#LC9
	jsr	_gFatal
	leas	2,s
L119:
	ldb	,s
	addb	#2
	pshs	b
	pshs	u
	ldx	#0
	ldb	#71
	jsr	_SendPacket
	leas	6,s
	puls	u,pc
_BonoboRecvChunkTry:
	pshs	y,u
	leas	-3,s
	leay	,x
	ldu	9,s
	jsr	_gIrqSaveAndDisable
	stb	,s
	ldd	#71
	cmpu	#0	;cmphi:
	beq	L129
	cmpu	#100	;cmphi:
	bls	L122
	ldd	#72
L129:
	std	,--s
	ldx	#LC8
	jsr	_gFatal
	leas	2,s
L122:
	ldb	#-6
	jsr	_bSendControl
	ldb	-150
	stb	1,s
	ldb	-150
	stb	2,s
	cmpu	1,s	;cmphi:
	bls	L123
	ldb	,s
	jsr	_gIrqRestore
	ldb	#1
	bra	L124
L123:
	ldd	#52
	cmpu	#0	;cmphi:
	beq	L130
	cmpu	#100	;cmphi:
	bls	L126
	ldd	#53
L130:
	std	,--s
	ldx	#LC8
	jsr	_gFatal
	leas	2,s
L126:
	tfr	u,d	;movlsbqihi: R:u -> R:b
	jsr	_bSendControl
	leax	,y
	ldy	#0
	bra	L127
L128:
	ldb	-150
	stb	,x+
	leay	1,y
L127:
	pshs	u	;cmphi: R:u with R:y
	cmpy	,s++	;cmphi:
	bne	L128
	ldb	,s
	jsr	_gIrqRestore
	clrb
L124:
	leas	3,s
	puls	y,u,pc
LC10:
	.ascii "nekot1/alloc64.c\0"
_gAlloc64:
	pshs	u
	leas	-3,s
	jsr	_gIrqSaveAndDisable
	stb	,s
	ldu	_root64
	beq	L132
	ldx	,u
	cmpx	#7905	;cmphi:
	beq	L133
	ldd	#17
	std	,--s
	ldx	#LC10
	jsr	_gFatal
	leas	2,s
L133:
	ldx	2,u
	stx	_root64
	ldd	#0
	std	,u
L132:
	ldb	,s
	jsr	_gIrqRestore
	leax	,u
	leas	3,s
	puls	u,pc
LC11:
	.ascii "RECV\0"
LC12:
	.ascii "E-M\0"
LC13:
	.ascii "E-P\0"
LC14:
	.ascii "RECV CAST NOMEM\0"
LC15:
	.ascii "E-C\0"
LC16:
	.ascii "XRC\0"
_CheckReceived:
	pshs	y,u
	leas	-15,s
	jsr	_gIrqSaveAndDisable
	stb	3,s
	ldb	_need_recv_payload
	bne	L135
	ldd	#5
	std	,--s
	leax	12,s
	jsr	_BonoboRecvChunkTry
	leas	2,s
	cmpb	#1	;cmpqi:
	lbeq	L136
	tstb	;cmpqi:(ZERO)
	beq	L137
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC11
	jsr	_gFatal
	leas	2,s
L137:
	ldb	#1
	stb	_need_recv_payload
L135:
	ldb	_Vdg+4
	orb	#2
	stb	-222
	ldb	10,s
	ldy	11,s
	ldu	13,s
	cmpb	#-52	;cmpqi:
	lbeq	L138
	cmpb	#65	;cmpqi:
	bne	L139
	cmpy	#6	;cmphi:
	beq	L140
	ldd	#48
	std	,--s
	ldx	#LC9
	jsr	_gFatal
	leas	2,s
L140:
	pshs	y
	leax	6,s
	jsr	_BonoboRecvChunkTry
	leas	2,s
	cmpb	#1	;cmpqi:
	lbeq	L141
	tstb	;cmpqi:(ZERO)
	beq	L142
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC12
	jsr	_gFatal
	leas	2,s
L142:
	ldx	4,s
	ldu	6,s
	ldy	8,s
	pshs	y
	pshs	u
	jsr	_gMemcpy
	leas	4,s
	jmp	L138
L139:
	cmpb	#66	;cmpqi:
	bne	L143
	pshs	y
	leax	,u
	jsr	_BonoboRecvChunkTry
	leas	2,s
	cmpb	#1	;cmpqi:
	lbeq	L141
	tstb	;cmpqi:(ZERO)
	lbeq	L138
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC13
	jmp	L161
L143:
	cmpb	#67	;cmpqi:
	bne	L144
	cmpy	#0	;cmphi:
	beq	L145
	ldd	#69
	std	,--s
	ldx	#LC9
	jsr	_gFatal
	leas	2,s
L145:
	jsr	,u
	jmp	L138
L144:
	cmpb	#68	;cmpqi:
	bne	L146
	cmpy	#0	;cmphi:
	beq	L147
	ldd	#74
	std	,--s
	ldx	#LC9
	jsr	_gFatal
	leas	2,s
L147:
	stu	_task_to_start
	ldb	#1
	stb	_need_to_start_task
	jmp	L138
L146:
	cmpb	#71	;cmpqi:
	lbne	L148
	jsr	_gIrqSaveAndDisable
	stb	2,s
	jsr	_gAlloc64
	stx	,s
	bne	L149
	ldd	#0
	std	,--s
	ldx	#LC14
	jsr	_gFatal
	leas	2,s
L149:
	ldd	#85
	cmpy	#1	;cmphi:
	bls	L160
	cmpy	#62	;cmphi:
	bls	L151
	ldd	#86
L160:
	std	,--s
	ldx	#LC9
	jsr	_gFatal
	leas	2,s
L151:
	ldx	,s
	leau	2,x
	pshs	y
	leax	,u
	jsr	_BonoboRecvChunkTry
	leas	2,s
	cmpb	#1	;cmpqi:
	bne	L152
	ldb	2,s
	jsr	_gIrqRestore
	bra	L141
L152:
	tstb	;cmpqi:(ZERO)
	beq	L153
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC15
	jsr	_gFatal
	leas	2,s
L153:
	ldd	#0
	ldx	,s
	std	62,x
	ldy	_recvcast_root
	bne	L158
	bra	L162
L157:
	leay	,x
L158:
	ldx	62,y
	bne	L157
	ldx	,s
	stx	62,y
	bra	L156
L162:
	ldx	,s
	stx	_recvcast_root
L156:
	ldu	_recvcast_root
	ldx	,s
	stu	62,x
	stx	_recvcast_root
	ldb	2,s
	jsr	_gIrqRestore
	bra	L138
L148:
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC16
L161:
	jsr	_gFatal
	leas	2,s
L138:
	clr	_need_recv_payload
L141:
	ldb	_Vdg+4
	stb	-222
	ldb	_need_to_start_task
	beq	L136
	clr	_need_to_start_task
	ldx	_task_to_start
	jsr	_StartTask
L136:
	ldb	3,s
	jsr	_gIrqRestore
	leas	15,s
	puls	y,u,pc
LC17:
	.ascii "nekot1/kern.c\0"
_Network_Handler:
	ldb	_gKern+6
	bne	L164
	ldx	#193
	stx	,--s
	ldx	#LC17
	jsr	_gFatal
	leas	2,s
L164:
	jmp	_CheckReceived
_ChatTask:
	jsr	_NowSwitchToChatScreen
	bra	L166
L169:
	ldb	_gKern+6
	beq	L167
	ldx	#183
	stx	,--s
	ldx	#LC17
	jsr	_gFatal
	leas	2,s
L167:
	ldb	_gKern+7
	beq	L168
	ldx	#184
	stx	,--s
	ldx	#LC17
	jsr	_gFatal
	leas	2,s
L168:
	jsr	_CheckReceived
	inc	526
	inc	16366
	ldb	16366
L166:
	ldb	_gKern+5
	bne	L169
	rts
LC18:
	.ascii "nekot1/keyboard.c\0"

	.area	.data
LC0:
	.byte	69
	.word	8
	.word	0

	.area	.text
_KeyboardHandler:
	pshs	y,u
	leas	-15,s
	ldb	_gKern+4
	lbne	L170
	ldb	_gKern+7
	bne	L172
	ldd	#29
	std	,--s
	ldx	#LC18
	jsr	_gFatal
	leas	2,s
L172:
	ldb	_Keyboard+16
	clra		;zero_extendqihi: R:b -> R:d
	std	4,s
	addd	#-1
	tfr	a,b
	clra		;zero_extendqihi: R:b -> R:d
	rolb
	rolb
	andb	#1
	stb	7,s
	clra		;zero_extendqihi: R:b -> R:d
	std	2,s
	aslb
	rola
	aslb
	rola
	aslb
	rola
	tfr	d,y
	leax	_Keyboard,y
	ldd	4,s
	aslb
	rola
	aslb
	rola
	aslb
	rola
	ldu	#_Keyboard
	leay	d,u
	sty	8,s
	ldu	#8
	clr	4,s
	ldb	#1
	stb	2,s
	sty	,s
L174:
	ldb	2,s
	comb
	stb	-254
	ldb	-256
	comb
	andb	#127
	ldy	8,s
	leay	1,y
	sty	8,s
	leay	-1,y
	stb	,y+
	cmpb	,x+	;cmpqi:
	beq	L173
	ldb	#1
	stb	4,s
L173:
	asl	2,s
	leau	-1,u
	cmpu	#0	;cmphi:
	bne	L174
	ldy	,s
	inc	530
	inc	16370
	ldb	16370
	ldb	4,s
	beq	L175
	ldd	#5
	std	,--s
	ldx	#LC0
	stx	,--s
	leax	14,s
	jsr	_memcpy
	ldd	#5
	std	,--s
	leax	16,s
	jsr	_BonoboSend
	ldd	#8
	std	,--s
	leax	,y
	jsr	_BonoboSend
	leas	8,s
L175:
	ldb	7,s
	stb	_Keyboard+16
L170:
	leas	15,s
	puls	y,u,pc
_Breakkey_Handler:
	ldb	#-5
	stb	-254
	ldb	-256
	clra		;zero_extendqihi: R:b -> R:d
	anda	#0
	andb	#64
	cmpd	#0	;cmphi:
	bne	L179
	ldb	_Breakkey
	bne	L180
	ldb	#1
	stb	_Breakkey
	ldb	_gKern+4
	bne	L182
L181:
	ldb	_gKern+6
	beq	L182
	ldb	#1
	stb	_gKern+4
	jsr	_NowSwitchToGameScreen
	bra	L180
L182:
	clr	_gKern+4
	jsr	_NowSwitchToChatScreen
L180:
	inc	542
	inc	16382
	ldb	16382
	bra	L178
L179:
	clr	_Breakkey
L178:
	rts
LC19:
	.ascii "nekot1/irq.c\0"
_Irq_Handler:
	ldb	#1
	stb	_gKern+7
	inc	534
	inc	16374
	ldb	16374
	ldb	-254
	ldb	_gReal
	cmpb	#4	;cmpqi:
	bhi	L185
	inc	_gReal
	ldb	_gReal
	jmp	L186
L185:
	clr	_gReal
	inc	535
	inc	16375
	ldb	16375
	ldb	_gReal+1
	cmpb	#8	;cmpqi:
	bhi	L187
	inc	_gReal+1
	ldb	_gReal+1
	jmp	L186
L187:
	clr	_gReal+1
	inc	536
	inc	16376
	ldb	16376
	ldx	_gReal+2
	leax	1,x
	stx	_gReal+2
	ldb	_gKern+6
	beq	L188
	ldx	#_SendPartialScores
	stx	0
L188:
	ldb	_gWall
	cmpb	#58	;cmpqi:
	bhi	L189
	inc	_gWall
	ldb	_gWall
	bra	L186
L189:
	clr	_gWall
	ldb	_gWall+1
	cmpb	#58	;cmpqi:
	bhi	L190
	inc	_gWall+1
	ldb	_gWall+1
	bra	L186
L190:
	clr	_gWall+1
	ldb	_gWall+2
	cmpb	#22	;cmpqi:
	bhi	L191
	inc	_gWall+2
	ldb	_gWall+2
	bra	L186
L191:
	clr	_gWall+2
	ldb	_gWall+14
	stb	_gWall+3
	ldb	_gWall+15
	stb	_gWall+4
	ldb	_gWall+16
	stb	_gWall+5
	ldd	#3
	std	,--s
	ldx	#_gWall+17
	stx	,--s
	ldx	#_gWall+6
	jsr	_gMemcpy
	ldd	#3
	std	,--s
	ldx	#_gWall+21
	stx	,--s
	ldx	#_gWall+10
	jsr	_gMemcpy
	leas	8,s
L186:
	jsr	_Breakkey_Handler
	ldb	_gReal
	cmpb	#5	;cmpqi:
	bls	L192
	ldd	#52
	std	,--s
	ldx	#LC19
	jsr	_gFatal
	leas	2,s
L192:
	ldb	_gKern+4
	beq	L193
	ldb	_gReal
	clra		;zero_extendqihi: R:b -> R:d
	aslb
	rola
	tfr	d,x
	ldx	_Irq_FocusGameSchedule,x
	bra	L196
L193:
	ldb	_gKern+6
	beq	L195
	ldb	_gReal
	clra		;zero_extendqihi: R:b -> R:d
	aslb
	rola
	tfr	d,x
	ldx	_Irq_PassiveGameSchedule,x
	bra	L196
L195:
	ldb	_gReal
	clra		;zero_extendqihi: R:b -> R:d
	aslb
	rola
	tfr	d,x
	ldx	_Irq_FocusShellSchedule,x
L196:
	jsr	,x
	clr	_gKern+7
	rts

	.globl	_memset
_memset:
	pshs	y,u
	leas	-3,s
	ldy	11,s
	ldb	10,s
	stb	2,s
	leau	,x
	ldd	#0
	bra	L200
L199:
	ldb	2,s
	stb	,u+
	ldd	,s
	addd	#1
L200:
	std	,s
	cmpy	,s	;cmphi:(R)
	bne	L199
	leas	3,s
	puls	y,u,pc

	.globl	_memcpy
_memcpy:
	pshs	y,u
	leas	-2,s
	ldy	8,s
	leau	,x
	ldd	#0
	bra	L204
L203:
	ldb	,y+
	stb	,u+
	ldd	,s
	addd	#1
L204:
	std	,s
	cmpd	10,s	;cmphi:
	bne	L203
	leas	2,s
	puls	y,u,pc
LC20:
	.ascii "MAIN\0"

	.area	.text.startup

	.globl	_main
_main:
	pshs	y,u
	leas	-16,s
	ldx	#0
	jsr	_ClearPage256
	ldx	#512
	jsr	_ClearPage256
	ldx	#768
	jsr	_ClearPage256
	ldx	#1024
	jsr	_ClearPage256
	ldd	#8
	std	,--s
	ldx	#280
	stx	,--s
	ldx	#24
	jsr	_memcpy
	ldb	#-128
	stb	-112
	clr	-111
	ldd	#0
	std	_root64
	ldx	#1024
	jsr	_gFree64
	ldx	#1088
	jsr	_gFree64
	ldx	#1152
	jsr	_gFree64
	ldx	#1216
	jsr	_gFree64
	clr	_gKern+6
	clr	_gKern+4
	clr	_gKern+7
	ldb	#1
	stb	_gKern+5
	leas	4,s
	ldx	#0
L206:
	ldy	_handlers,x
	ldu	_coco2_relays,x
	ldb	#126
	stb	,u+
	sty	,u
	ldu	_coco3_relays,x
	stb	,u+
	sty	,u
	leax	2,x
	cmpx	#12	;cmphi:
	bne	L206
	ldx	#512
L207:
	ldu	#-29556
	stu	,x++
	cmpx	#544	;cmphi:
	bne	L207
L208:
	ldu	#8224
	stu	,x++
	cmpx	#992	;cmphi:
	bne	L208
L209:
	ldu	#-23645
	stu	,x++
	cmpx	#1024	;cmphi:
	bne	L209
	ldx	#960
	stx	_Console
	ldb	#-1
	stb	960
	ldx	#_pia_reset_sequence
	bra	L210
L211:
	ldb	2,x
	stb	,u
	leax	3,x
L210:
	ldu	,x
	bne	L211
	jsr	_NowSwitchToChatScreen
	ldb	#86
	jsr	_PutChar
	ldx	#_StrNekotMicrokernel
	jsr	_PutStr
	ldb	#67
	stb	525
	ldb	#75
	stb	529
	ldb	#81
	stb	533
	ldb	#66
	stb	541
	ldb	#-4
	jsr	_bSendControl
	ldb	#66
	jsr	_PutChar
	ldb	#78
	jsr	_PutChar
	ldb	#110
	stb	,s
	ldb	#101
	stb	1,s
	ldb	#107
	stb	2,s
	ldb	#111
	stb	3,s
	ldb	#116
	stb	4,s
	ldb	#49
	stb	5,s
	clr	6,s
	clr	7,s
	ldb	#2
	stb	8,s
	clr	9,s
	clr	10,s
	ldb	#8
	stb	11,s
	ldd	#_gScore
	tfr	a,b
	clra		;zero_extendqihi: R:b -> R:d
	stb	12,s	;movlsbqihi: R:d -> 12,s
	ldd	#_gScore
	stb	13,s	;movlsbqihi: R:d -> 13,s
	ldd	#_gWall
	tfr	a,b
	clra		;zero_extendqihi: R:b -> R:d
	stb	14,s	;movlsbqihi: R:d -> 14,s
	ldd	#_gWall
	stb	15,s	;movlsbqihi: R:d -> 15,s
	ldb	#91
	jsr	_PutChar
	leay	,s
	leax	,s
	jsr	_PutStr
	ldb	#16
	stb	,-s
	pshs	y
	ldx	#1
	ldb	#64
	jsr	_SendPacket
	ldb	#72
	jsr	_PutChar
	ldb	#8
	stb	,-s
	ldx	#280
	stx	,--s
	ldx	#2
	ldb	#64
	jsr	_SendPacket
	ldb	#93
	jsr	_PutChar
	ldb	-254
	ldb	#53
	stb	-253
	ldx	#_StrReady
	jsr	_PutStr
	jsr	_embark
	ldx	#_PinDownGlobalNames
	stx	,u
	ldd	#0
	std	,--s
	ldx	#LC20
	jsr	_gFatal
	ldx	#0
	leas	24,s
	puls	y,u,pc

	.area	.text

	.globl	_strlen
_strlen:
	pshs	y,u
	leay	,x
L217:
	leau	,y
	leay	1,y
	ldb	,u
	bne	L217
	tfr	u,d
	pshs	x	;subhi: R:d -= R:x
	subd	,s++
	tfr	d,x
	puls	y,u,pc
_gNetworkLog:
	pshs	u
	leau	,x
	jsr	_strlen
	tfr	x,d
	pshs	b
	pshs	u
	ldx	#0
	ldb	#-56
	jsr	_SendPacket
	leas	3,s
	puls	u,pc

	.area	.bss
_SavedStackPointer:	.blkb	2
_slow_her_down:	.blkb	2

	.area	.data.startup
_PinDownGlobalNames:
	.word	_embark
	.word	_Breakkey_Handler
	.word	_Irq_Handler
	.word	_Irq_Handler_entry
	.word	_Irq_Handler_Wrapper
	.word	_Network_Handler
	.word	_gAlloc64
	.word	_gFree64
	.word	_Reset64
	.word	_gSendCast
	.word	_gReceiveCast64
	.word	_gTextScreen
	.word	_gPMode1Screen
	.word	_gModeScreen
	.word	_xAfterSetup
	.word	_xSendControlPacket
	.word	_gNetworkLog
	.word	_gFatal
	.word	_PutStr
	.word	_PutChar
	.word	_entry_wrapper
	.word	__More0
	.word	__More1
	.word	__Final
	.word	__Final_Startup
	.word	_gScore
	.word	_gReal
	.word	_gWall
	.word	_gConfig

	.area	.final
__Final:
	.word	-26224

	.area	.final.startup
__Final_Startup:
	.word	-26223

	.area	.data.more
_gScore:
	zmb	50	;skip space

	.area	.bss
_gReal:	.blkb	4
_gWall:	.blkb	25
_Console:	.blkb	2
_Vdg:	.blkb	5
_gKern:	.blkb	10
_recvcast_root:	.blkb	2
_root64:	.blkb	2
_need_recv_payload:	.blkb	1
_need_to_start_task:	.blkb	1
_task_to_start:	.blkb	2

	.area	.text
_Irq_FocusGameSchedule:
	.word	_Network_Handler
	.word	_Breakkey_Handler
	.word	_Network_Handler
	.word	_Breakkey_Handler
	.word	_Network_Handler
	.word	_Breakkey_Handler
_Irq_PassiveGameSchedule:
	.word	_Network_Handler
	.word	_Breakkey_Handler
	.word	_Network_Handler
	.word	_KeyboardHandler
	.word	_Network_Handler
	.word	_KeyboardHandler
_Irq_FocusShellSchedule:
	.word	_KeyboardHandler
	.word	_Breakkey_Handler
	.word	_KeyboardHandler
	.word	_Breakkey_Handler
	.word	_KeyboardHandler
	.word	_Breakkey_Handler

	.area	.data.more
_Keyboard:
	zmb	17	;skip space

	.area	.bss
_Breakkey:	.blkb	1

	.area	.data.startup
_handlers:
	.word	_gFatalSWI3
	.word	_gFatalSWI2
	.word	_gFatalFIRQ
	.word	_Irq_Handler_entry
	.word	_gFatalSWI1
	.word	_gFatalNMI
_coco2_relays:
	.word	256
	.word	259
	.word	271
	.word	268
	.word	262
	.word	265
_coco3_relays:
	.word	-18
	.word	-15
	.word	-12
	.word	-9
	.word	-6
	.word	-3
_pia_reset_sequence:
	.word	-223
	.byte	0
	.word	-221
	.byte	0
	.word	-224
	.byte	-2
	.word	-222
	.byte	-6
	.word	-223
	.byte	52
	.word	-221
	.byte	52
	.word	-222
	.byte	0
	.word	-224
	.byte	2
	.word	-255
	.byte	0
	.word	-253
	.byte	0
	.word	-256
	.byte	0
	.word	-254
	.byte	-1
	.word	-255
	.byte	52
	.word	-253
	.byte	52
	.word	0
	zmb	1	;skip space
_StrNekotMicrokernel:
	.ascii "\nNEKOT MICROKERNEL... \0"
_StrReady:
	.ascii " READY\n\0"

	.area	.text
_HexAlphabet:
	.ascii "0123456789ABCDEF\0"

	.area	.data.more
__More0:
	zmb	2	;skip space
__More1:
	.word	-26216

	.area	.text
LC21:
	.ascii "bonobo\0"

	.area	.data
_gConfig:
	.word	16384
	.word	LC21
