
;;; gcc for m6809 : Apr  3 2025 06:14:16
;;; 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	#1056
L4:
	leay	32,u
	ldd	,y
	std	,u++
	cmpu	#1472	;cmphi:
	bne	L4
L5:
	ldy	#8224
	sty	,u++
	cmpu	#1504	;cmphi:
	bne	L5
	leax	-32,x
L3:
	cmpx	#1503	;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	#1502	;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 -----
;  65 "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 -----
;  114 "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 -----
;  126 "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 -----
;  141 "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
_Delay:
	pshs	u
	ldu	#0
	bra	L50
L51:
;----- asm -----
;  96 "nekot1/main.c" 1
	 mul 
 mul 
 mul 
 mul 
 mul
;--- end asm ---
	leau	1,u
L50:
	pshs	x	;cmphi: R:x with R:u
	cmpu	,s++	;cmphi:
	bne	L51
	puls	u,pc
LC1:
	.ascii "*** \0"
_ColdPrint:
	pshs	u
	leau	,x
	ldx	#LC1
	jsr	_PutStr
	leax	,u
	jsr	_PutStr
	ldb	#10
	jsr	_PutChar
	ldb	#-17
	stb	-254
	ldb	-256
	comb
	andb	#8
	ldx	#15000
	tstb	;cmpqi:(ZERO)
	bne	L54
	ldx	#1000
L54:
	puls	u
	jmp	_Delay
_entry_wrapper:
;----- asm -----
;  150 "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	L57
	ldx	62,u
	stx	_recvcast_root
L57:
	jsr	_gIrqRestore
	ldd	#0
	std	62,u
	leax	,u
	puls	u,pc
_memcpy_words:
	pshs	y,u
	ldy	6,s
	ldd	#0
	bra	L59
L60:
	ldu	,y++
	stu	,x++
	addd	#1
L59:
	cmpd	8,s	;cmphi:
	bne	L60
	puls	y,u,pc
_memset_words:
	pshs	y,u
	ldy	6,s
	ldu	8,s
	ldd	#0
	bra	L62
L63:
	sty	,x++
	addd	#1
L62:
	pshs	u	;cmphi: R:u with R:d
	cmpd	,s++	;cmphi:
	bne	L63
	puls	y,u,pc

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

	.globl	_memcpy
_memcpy:
	pshs	y,u
	leas	-2,s
	ldy	8,s
	leau	,x
	ldd	#0
	bra	L71
L70:
	ldb	,y+
	stb	,u+
	ldd	,s
	addd	#1
L71:
	std	,s
	cmpd	10,s	;cmphi:
	bne	L70
	leas	2,s
	puls	y,u,pc

	.globl	_strlen
_strlen:
	pshs	y,u
	leay	,x
L73:
	leau	,y
	leay	1,y
	ldb	,u
	bne	L73
	tfr	u,d
	pshs	x	;subhi: R:d -= R:x
	subd	,s++
	tfr	d,x
	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
L77:
	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	L77
	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	L83
	ldd	#2048
	bra	L81
L83:
	ldd	#0
L81:
	std	_Vdg
	stx	_Vdg+2
	ldb	_gKern+4
	beq	L80
	jsr	_NowSwitchToGameScreen
L80:
	rts
_StartTask:
	pshs	u
	leas	-2,s
	stx	,s
;----- asm -----
;  70 "nekot1/kern.c" 1
	  orcc #$10
;--- end asm ---
	cmpx	#0	;cmphi:
	bne	L85
	ldx	#_ChatTask
	stx	,s
L85:
	ldd	#64
	std	,--s
	ldd	#0
	std	,--s
	ldx	#128
	jsr	_memset_words
	leas	4,s
	ldx	,s
	cmpx	#_ChatTask	;cmphi:
	bne	L86
	clr	_gKern+6
	clr	_gKern+4
	bra	L87
L86:
	ldb	#1
	stb	_gKern+6
	stb	_gKern+4
	ldx	#1024
	jsr	_gTextScreen
L87:
	ldd	#8
	std	,--s
	ldx	#16191
	stx	,--s
	ldx	#0
	jsr	_memset_words
	ldx	#256
	stx	,--s
	ldx	#16191
	stx	,--s
	ldx	#512
	jsr	_memset_words
	ldd	#0
	std	_root64
	leas	8,s
	ldu	#512
L88:
	leax	,u
	jsr	_gFree64
	leau	64,u
	cmpu	#1024	;cmphi:
	bne	L88
	clr	_gKern+7
;----- asm -----
;  101 "nekot1/kern.c" 1
	
  ldx   ,s      
  lds   #$01FE  
  andcc #^$50   
  jmp   ,X      

;--- end asm ---
	leas	2,s
	puls	u,pc
_embark:
	ldd	#__Final_Startup
	subd	#__Final	;subhi: R:d -= #__Final
	lsra
	rorb
	pshs	d
	ldx	#16191
	stx	,--s
	ldx	#__Final
	jsr	_memset_words
	leas	4,s
	ldx	#_ChatTask
	jmp	_StartTask
_gPMode1Screen:
	pshs	u
	ldu	#-16380
	tstb	;cmpqi:(ZERO)
	beq	L92
	ldu	#-14332
L92:
	stu	_Vdg
	stx	_Vdg+2
	ldb	_gKern+4
	beq	L91
	jsr	_NowSwitchToGameScreen
L91:
	puls	u,pc
_gModeScreen:
	pshs	u
	ldu	4,s
	stu	_Vdg
	stx	_Vdg+2
	ldb	_gKern+4
	beq	L95
	jsr	_NowSwitchToGameScreen
L95:
	puls	u,pc
_NowSwitchToChatScreen:
	ldb	_gKern+6
	beq	L99
	ldb	#8
	bra	L98
L99:
	clrb
L98:
	clr	,-s
	ldx	#1024
	jsr	_NowSwitchDisplayMode
	leas	1,s
	rts
LC2:
	.ascii "\nFATAL \0"
LC3:
	.ascii ": \0"
LC4:
	.ascii "\n$\0"
_gFatal:
	pshs	y,u
	leas	-4,s
	leau	4,s
	stx	,--u
;----- asm -----
;  15 "nekot1/kern.c" 1
	  orcc #$10
;--- end asm ---
	ldx	#_gFatal
	stx	0
	stu	0
	leax	10,s
	stx	2
	jsr	_NowSwitchToChatScreen
	ldx	#LC2
	jsr	_PutStr
	ldx	10,s
	jsr	_PutDec
	ldx	#LC3
	jsr	_PutStr
	ldx	2,s
	jsr	_PutStr
	ldx	#LC4
	jsr	_PutStr
	ldy	4
	leax	,y
	jsr	_PutHex
	ldx	#LC3
	jsr	_PutStr
	ldu	#0
L103:
	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	L101
	ldb	#44
	jsr	_PutChar
L101:
	tfr	u,d
	anda	#0
	andb	#15
	cmpd	#15	;cmphi:
	bne	L102
	ldb	#59
	jsr	_PutChar
L102:
	ldb	#32
	jsr	_PutChar
	leau	1,u
	cmpu	#32	;cmphi:
	bne	L103
	ldb	#36
	jsr	_PutChar
	bra	L104
L105:
	ldx	1024
	leax	1,x
	stx	1024
L104:
	ldb	_gKern+5
	bne	L105
	leas	4,s
	puls	y,u,pc
LC5:
	.ascii "FIRQ\0"
_gFatalFIRQ:
;----- asm -----
;  58 "nekot1/kern.c" 1
	sts _gKern+10
;--- end asm ---
	ldx	_gKern+10
	pshs	x
	ldx	#LC5
	jsr	_gFatal
	leas	2,s
	rts
LC6:
	.ascii "NMI\0"
_gFatalNMI:
;----- asm -----
;  54 "nekot1/kern.c" 1
	sts _gKern+10
;--- end asm ---
	ldx	_gKern+10
	pshs	x
	ldx	#LC6
	jsr	_gFatal
	leas	2,s
	rts
LC7:
	.ascii "SWI3\0"
_gFatalSWI3:
;----- asm -----
;  50 "nekot1/kern.c" 1
	sts _gKern+10
;--- end asm ---
	ldx	_gKern+10
	pshs	x
	ldx	#LC7
	jsr	_gFatal
	leas	2,s
	rts
LC8:
	.ascii "SWI2\0"
_gFatalSWI2:
;----- asm -----
;  46 "nekot1/kern.c" 1
	sts _gKern+10
;--- end asm ---
	ldx	_gKern+10
	pshs	x
	ldx	#LC8
	jsr	_gFatal
	leas	2,s
	rts
LC9:
	.ascii "SWI\0"
_gFatalSWI1:
;----- asm -----
;  42 "nekot1/kern.c" 1
	sts _gKern+10
;--- end asm ---
	ldx	_gKern+10
	pshs	x
	ldx	#LC9
	jsr	_gFatal
	leas	2,s
	rts
LC10:
	.ascii "BONOBO\0"
_bSendControl:
	stb	-152
	ldx	#-9981
L114:
	ldb	-152
	cmpb	#98	;cmpqi:
	beq	L112
	leax	-1,x
	cmpx	#0	;cmphi:
	bne	L114
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC10
	jsr	_gFatal
	leas	2,s
L112:
	rts
LC11:
	.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	L117
	ldd	#86
	std	,--s
	ldx	#LC11
	jsr	_gFatal
	ldd	#59
	bra	L121
L117:
	cmpu	#100	;cmphi:
	bls	L118
	ldd	#87
	std	,--s
	ldx	#LC11
	jsr	_gFatal
	ldd	#60
L121:
	std	,--s
	ldx	#LC11
	jsr	_gFatal
	leas	4,s
L118:
	tfr	u,d	;movlsbqihi: R:u -> R:b
	addb	#100
	jsr	_bSendControl
	leax	,y
	ldy	#0
	bra	L119
L120:
	ldb	,x+
	stb	-150
	leay	1,y
L119:
	pshs	u	;cmphi: R:u with R:y
	cmpy	,s++	;cmphi:
	bne	L120
	ldb	#-5
	jsr	_bSendControl
	ldb	,s
	leas	1,s
	puls	y,u
	jmp	_gIrqRestore
_SendPacket:
	pshs	u
	leas	-8,s
	stb	3,s
	ldb	14,s
	cmpb	#64	;cmpqi:
	bls	L123
	ldb	#64
L123:
	clra		;zero_extendqihi: R:b -> R:d
	tfr	d,u
	std	4,s
	stx	6,s
	jsr	_gIrqSaveAndDisable
	stb	,s
	ldd	#5
	std	,--s
	leax	d,s
	jsr	_BonoboSend
	pshs	u
	ldx	16,s
	jsr	_BonoboSend
	ldb	4,s
	jsr	_gIrqRestore
	leas	12,s
	puls	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
_xSendControlPacket:
	ldb	5,s
	stb	4,s
	ldb	#70
	jmp	_SendPacket
LC12:
	.ascii "nekot1/network.c\0"
_gSendCast:
	pshs	u
	leas	-3,s
	leau	,x
	stb	,s
	cmpb	#60	;cmpqi:
	bls	L127
	ldd	#28
	std	,--s
	ldx	#LC12
	jsr	_gFatal
	leas	2,s
L127:
	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	L137
	cmpu	#100	;cmphi:
	bls	L130
	ldd	#72
L137:
	std	,--s
	ldx	#LC11
	jsr	_gFatal
	leas	2,s
L130:
	ldb	#-6
	jsr	_bSendControl
	ldb	-150
	stb	1,s
	ldb	-150
	stb	2,s
	cmpu	1,s	;cmphi:
	bls	L131
	ldb	,s
	jsr	_gIrqRestore
	ldb	#1
	bra	L132
L131:
	ldd	#52
	cmpu	#0	;cmphi:
	beq	L138
	cmpu	#100	;cmphi:
	bls	L134
	ldd	#53
L138:
	std	,--s
	ldx	#LC11
	jsr	_gFatal
	leas	2,s
L134:
	tfr	u,d	;movlsbqihi: R:u -> R:b
	jsr	_bSendControl
	leax	,y
	ldy	#0
	bra	L135
L136:
	ldb	-150
	stb	,x+
	leay	1,y
L135:
	pshs	u	;cmphi: R:u with R:y
	cmpy	,s++	;cmphi:
	bne	L136
	ldb	,s
	jsr	_gIrqRestore
	clrb
L132:
	leas	3,s
	puls	y,u,pc
LC13:
	.ascii "nekot1/alloc64.c\0"
_gAlloc64:
	pshs	u
	leas	-3,s
	jsr	_gIrqSaveAndDisable
	stb	,s
	ldu	_root64
	beq	L140
	ldx	,u
	cmpx	#7905	;cmphi:
	beq	L141
	ldd	#17
	std	,--s
	ldx	#LC13
	jsr	_gFatal
	leas	2,s
L141:
	ldx	2,u
	stx	_root64
	ldd	#0
	std	,u
L140:
	ldb	,s
	jsr	_gIrqRestore
	leax	,u
	leas	3,s
	puls	u,pc
LC14:
	.ascii "RECV\0"
LC15:
	.ascii "E-M\0"
LC16:
	.ascii "E-P\0"
LC17:
	.ascii "RECV CAST NOMEM\0"
LC18:
	.ascii "E-C\0"
LC19:
	.ascii "XRC\0"
_CheckReceived:
	pshs	y,u
	leas	-15,s
	jsr	_gIrqSaveAndDisable
	stb	3,s
	ldb	_need_recv_payload
	bne	L143
	ldd	#5
	std	,--s
	leax	12,s
	jsr	_BonoboRecvChunkTry
	leas	2,s
	cmpb	#1	;cmpqi:
	lbeq	L144
	tstb	;cmpqi:(ZERO)
	beq	L145
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC14
	jsr	_gFatal
	leas	2,s
L145:
	ldb	#1
	stb	_need_recv_payload
L143:
	ldb	_Vdg+4
	orb	#2
	stb	-222
	ldb	10,s
	ldy	11,s
	ldu	13,s
	cmpb	#-52	;cmpqi:
	lbeq	L146
	cmpb	#65	;cmpqi:
	bne	L147
	cmpy	#6	;cmphi:
	beq	L148
	ldd	#60
	std	,--s
	ldx	#LC12
	jsr	_gFatal
	leas	2,s
L148:
	pshs	y
	leax	6,s
	jsr	_BonoboRecvChunkTry
	leas	2,s
	cmpb	#1	;cmpqi:
	lbeq	L149
	tstb	;cmpqi:(ZERO)
	beq	L150
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC15
	jsr	_gFatal
	leas	2,s
L150:
	ldx	4,s
	ldu	6,s
	ldy	8,s
	pshs	y
	pshs	u
	jsr	_memcpy
	leas	4,s
	jmp	L146
L147:
	cmpb	#66	;cmpqi:
	bne	L151
	pshs	y
	leax	,u
	jsr	_BonoboRecvChunkTry
	leas	2,s
	cmpb	#1	;cmpqi:
	lbeq	L149
	tstb	;cmpqi:(ZERO)
	lbeq	L146
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC16
	jmp	L169
L151:
	cmpb	#67	;cmpqi:
	bne	L152
	cmpy	#0	;cmphi:
	beq	L153
	ldd	#81
	std	,--s
	ldx	#LC12
	jsr	_gFatal
	leas	2,s
L153:
	jsr	,u
	jmp	L146
L152:
	cmpb	#68	;cmpqi:
	bne	L154
	cmpy	#0	;cmphi:
	beq	L155
	ldd	#86
	std	,--s
	ldx	#LC12
	jsr	_gFatal
	leas	2,s
L155:
	stu	_task_to_start
	ldb	#1
	stb	_need_to_start_task
	jmp	L146
L154:
	cmpb	#71	;cmpqi:
	lbne	L156
	jsr	_gIrqSaveAndDisable
	stb	2,s
	jsr	_gAlloc64
	stx	,s
	bne	L157
	ldd	#0
	std	,--s
	ldx	#LC17
	jsr	_gFatal
	leas	2,s
L157:
	ldd	#97
	cmpy	#1	;cmphi:
	bls	L168
	cmpy	#62	;cmphi:
	bls	L159
	ldd	#98
L168:
	std	,--s
	ldx	#LC12
	jsr	_gFatal
	leas	2,s
L159:
	ldx	,s
	leau	2,x
	pshs	y
	leax	,u
	jsr	_BonoboRecvChunkTry
	leas	2,s
	cmpb	#1	;cmpqi:
	bne	L160
	ldb	2,s
	jsr	_gIrqRestore
	bra	L149
L160:
	tstb	;cmpqi:(ZERO)
	beq	L161
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC18
	jsr	_gFatal
	leas	2,s
L161:
	ldd	#0
	ldx	,s
	std	62,x
	ldy	_recvcast_root
	bne	L166
	bra	L170
L165:
	leay	,x
L166:
	ldx	62,y
	bne	L165
	ldx	,s
	stx	62,y
	bra	L164
L170:
	ldx	,s
	stx	_recvcast_root
L164:
	ldu	_recvcast_root
	ldx	,s
	stu	62,x
	stx	_recvcast_root
	ldb	2,s
	jsr	_gIrqRestore
	bra	L146
L156:
	clra		;zero_extendqihi: R:b -> R:d
	pshs	d
	ldx	#LC19
L169:
	jsr	_gFatal
	leas	2,s
L146:
	clr	_need_recv_payload
L149:
	ldb	_Vdg+4
	stb	-222
	ldb	_need_to_start_task
	beq	L144
	clr	_need_to_start_task
	ldx	_task_to_start
	jsr	_StartTask
L144:
	ldb	3,s
	jsr	_gIrqRestore
	leas	15,s
	puls	y,u,pc
LC20:
	.ascii "nekot1/kern.c\0"
_Network_Handler:
	ldb	_gKern+6
	bne	L172
	ldx	#174
	stx	,--s
	ldx	#LC20
	jsr	_gFatal
	leas	2,s
L172:
	jmp	_CheckReceived
_ChatTask:
	jsr	_NowSwitchToChatScreen
	bra	L174
L177:
	ldb	_gKern+6
	beq	L175
	ldx	#164
	stx	,--s
	ldx	#LC20
	jsr	_gFatal
	leas	2,s
L175:
	ldb	_gKern+7
	beq	L176
	ldx	#165
	stx	,--s
	ldx	#LC20
	jsr	_gFatal
	leas	2,s
L176:
	jsr	_CheckReceived
	inc	1038
	inc	16366
	ldb	16366
L174:
	ldb	_gKern+5
	bne	L177
	rts
_SplashRestore:
	pshs	y,u
	leas	-2,s
	ldy	8,s
	cmpx	#0	;cmphi:
	blt	L178
	cmpy	#0	;cmphi:
	blt	L178
	cmpx	#31	;cmphi:
	bgt	L178
	cmpy	#15	;cmphi:
	bgt	L178
	tfr	y,d
	aslb
	rola
	aslb
	rola
	aslb
	rola
	aslb
	rola
	aslb
	rola
	leau	d,x
	leau	1024,u
	tfr	y,d
	addd	#16
	aslb
	rola
	aslb
	rola
	aslb
	rola
	aslb
	rola
	aslb
	rola
	leax	d,x
	ldb	,x
	stb	,u
L178:
	leas	2,s
	puls	y,u,pc
_SplashSet:
	ldd	2,s
	cmpx	#0	;cmphi:
	blt	L180
	cmpd	#0	;cmphi:
	blt	L180
	cmpx	#31	;cmphi:
	bgt	L180
	cmpd	#15	;cmphi:
	bgt	L180
	aslb
	rola
	aslb
	rola
	aslb
	rola
	aslb
	rola
	aslb
	rola
	leax	d,x
	leax	1024,x
	ldb	#-1
	stb	,x
L180:
	rts
LC21:
	.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	L182
	ldb	_gKern+7
	bne	L184
	ldd	#29
	std	,--s
	ldx	#LC21
	jsr	_gFatal
	leas	2,s
L184:
	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
L186:
	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	L185
	ldb	#1
	stb	4,s
L185:
	asl	2,s
	leau	-1,u
	cmpu	#0	;cmphi:
	bne	L186
	ldy	,s
	inc	1042
	inc	16370
	ldb	16370
	ldb	4,s
	beq	L187
	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
L187:
	ldb	7,s
	stb	_Keyboard+16
L182:
	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	L191
	ldb	_Breakkey
	bne	L192
	ldb	#1
	stb	_Breakkey
	ldb	_gKern+4
	bne	L194
L193:
	ldb	_gKern+6
	beq	L194
	ldb	#1
	stb	_gKern+4
	jsr	_NowSwitchToGameScreen
	bra	L192
L194:
	clr	_gKern+4
	jsr	_NowSwitchToChatScreen
L192:
	inc	1054
	inc	16382
	ldb	16382
	bra	L190
L191:
	clr	_Breakkey
L190:
	rts
LC22:
	.ascii "nekot1/irq.c\0"
_Irq_Handler:
	ldb	#1
	stb	_gKern+7
	inc	1046
	inc	16374
	ldb	16374
	ldb	-254
	ldb	_gReal
	cmpb	#4	;cmpqi:
	bhi	L197
	inc	_gReal
	ldb	_gReal
	jmp	L198
L197:
	clr	_gReal
	inc	1047
	inc	16375
	ldb	16375
	ldb	_gReal+1
	cmpb	#8	;cmpqi:
	bhi	L199
	inc	_gReal+1
	ldb	_gReal+1
	jmp	L198
L199:
	clr	_gReal+1
	inc	1048
	inc	16376
	ldb	16376
	ldx	_gReal+2
	leax	1,x
	stx	_gReal+2
	ldb	_gKern+6
	beq	L200
	ldx	#_SendPartialScores
	stx	0
L200:
	ldb	_gWall
	cmpb	#58	;cmpqi:
	bhi	L201
	inc	_gWall
	ldb	_gWall
	bra	L198
L201:
	clr	_gWall
	ldb	_gWall+1
	cmpb	#58	;cmpqi:
	bhi	L202
	inc	_gWall+1
	ldb	_gWall+1
	bra	L198
L202:
	clr	_gWall+1
	ldb	_gWall+2
	cmpb	#22	;cmpqi:
	bhi	L203
	inc	_gWall+2
	ldb	_gWall+2
	bra	L198
L203:
	clr	_gWall+2
	ldb	_gWall+14
	stb	_gWall+3
	ldb	_gWall+15
	stb	_gWall+4
	ldb	_gWall+16
	stb	_gWall+5
	ldx	_gWall+17
	stx	_gWall+6
	ldb	_gWall+19
	stb	_gWall+8
	ldx	_gWall+21
	stx	_gWall+10
	ldb	_gWall+23
	stb	_gWall+12
L198:
	jsr	_Breakkey_Handler
	ldb	_gReal
	cmpb	#5	;cmpqi:
	bls	L204
	ldd	#50
	std	,--s
	ldx	#LC22
	jsr	_gFatal
	leas	2,s
L204:
	ldb	_gKern+4
	beq	L205
	ldb	_gReal
	clra		;zero_extendqihi: R:b -> R:d
	aslb
	rola
	tfr	d,x
	ldx	_Irq_FocusGameSchedule,x
	bra	L208
L205:
	ldb	_gKern+6
	beq	L207
	ldb	_gReal
	clra		;zero_extendqihi: R:b -> R:d
	aslb
	rola
	tfr	d,x
	ldx	_Irq_PassiveGameSchedule,x
	bra	L208
L207:
	ldb	_gReal
	clra		;zero_extendqihi: R:b -> R:d
	aslb
	rola
	tfr	d,x
	ldx	_Irq_FocusShellSchedule,x
L208:
	jsr	,x
	clr	_gKern+7
	rts
LC23:
	.ascii " \n\n\0"
LC24:
	.ascii "INIT\0"
LC25:
	.ascii "VECT\0"
LC26:
	.ascii "D4\0"
LC27:
	.ascii "D6\0"
LC28:
	.ascii "D8\0"
LC29:
	.ascii "DB\0"
LC30:
	.ascii "DC\0"
LC31:
	.ascii "DF\0"
LC32:
	.ascii "GIME\0"
LC33:
	.ascii "COMPAT\0"
LC34:
	.ascii "ZERO\0"
LC35:
	.ascii "HASH\0"
LC36:
	.ascii "KERN\0"
LC37:
	.ascii "VDG\0"
LC38:
	.ascii "MAIN\0"

	.area	.text.startup

	.globl	_main
_main:
	pshs	y,u
	leas	-24,s
	ldx	#_entry_wrapper
	stx	0
	ldy	#_PinDownGlobalNames
	sty	0
	ldd	#64
	std	,--s
	ldd	#0
	std	,--s
	ldx	#0
	jsr	_memset_words
	leas	4,s
	ldx	#_pia_reset_sequence
	bra	L210
L211:
	ldb	2,x
	stb	,u
	leax	3,x
L210:
	ldu	,x
	bne	L211
	ldb	#-120
	stb	-112
	clr	-111
	ldx	#-64
L213:
	ldu	#1
	cmpx	#-56	;cmphi:
	beq	L212
	ldu	#0
L212:
	exg	d,x
	leau	d,u
	exg	d,x
	clr	,u
	leax	2,x
	cmpx	#-44	;cmphi:
	bne	L213
	ldx	#256
	stx	,--s
	ldy	#1024
	sty	,--s
	ldx	#512
	jsr	_memcpy_words
	leas	4,s
	ldy	#8
L222:
	leax	8,y
	stx	,s
	leau	,x
	bra	L214
L215:
	pshs	y
	leax	,u
	jsr	_SplashSet
	ldd	#16
	pshs	y	;subhi: R:d -= R:y
	subd	,s++
	pshs	d
	leax	,u
	jsr	_SplashSet
	leau	1,u
	leas	4,s
L214:
	ldd	#23
	pshs	y	;subhi: R:d -= R:y
	subd	,s++
	pshs	u	;cmphi: R:u with R:d
	cmpd	,s++	;cmphi:
	bge	L215
	std	6,s
	sty	4,s
	leau	,y
	bra	L216
L217:
	pshs	u
	ldx	2,s
	jsr	_SplashSet
	ldd	#24
	pshs	y	;subhi: R:d -= R:y
	subd	,s++
	pshs	u
	tfr	d,x
	jsr	_SplashSet
	leau	1,u
	leas	4,s
L216:
	ldd	#15
	pshs	y	;subhi: R:d -= R:y
	subd	,s++
	pshs	u	;cmphi: R:u with R:d
	cmpd	,s++	;cmphi:
	bge	L217
	std	2,s
	ldx	#100
	jsr	_Delay
	ldu	,s
	bra	L218
L219:
	pshs	y
	leax	,u
	jsr	_SplashRestore
	ldd	#16
	pshs	y	;subhi: R:d -= R:y
	subd	,s++
	pshs	d
	leax	,u
	jsr	_SplashRestore
	leau	1,u
	leas	4,s
L218:
	cmpu	6,s	;cmphi:(R)
	ble	L219
	ldu	4,s
	bra	L233
L221:
	pshs	u
	ldx	2,s
	jsr	_SplashRestore
	ldd	#24
	pshs	y	;subhi: R:d -= R:y
	subd	,s++
	pshs	u
	tfr	d,x
	jsr	_SplashRestore
	leau	1,u
	leas	4,s
L233:
	cmpu	2,s	;cmphi:(R)
	ble	L221
	leay	-1,y
	cmpy	#-8	;cmphi:
	lbne	L222
	ldy	#1472
	sty	_Console
	ldx	#LC23
	jsr	_PutStr
	ldu	_Console
	ldb	#-1
	stb	,u
	ldx	#1024
L223:
	ldy	#-29556
	sty	,x++
	cmpx	#1056	;cmphi:
	bne	L223
	ldx	#1504
L224:
	ldy	#-23645
	sty	,x++
	cmpx	#1536	;cmphi:
	bne	L224
	ldb	#-1
	stb	,u
	ldx	#LC24
	jsr	_ColdPrint
	ldx	#_StrNekotOS
	jsr	_ColdPrint
	ldx	#0
L225:
	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	L225
	ldx	#LC25
	jsr	_ColdPrint
	clr	-44
	ldx	#LC26
	jsr	_ColdPrint
	clr	-42
	ldx	#LC27
	jsr	_ColdPrint
	clr	-40
	ldx	#LC28
	jsr	_ColdPrint
	clr	-37
	ldx	#LC29
	jsr	_ColdPrint
	clr	-36
	ldx	#LC30
	jsr	_ColdPrint
	clr	-33
	ldx	#LC31
	jsr	_ColdPrint
	ldx	#_gime_reset_sequence
	bra	L226
L227:
	ldb	2,x
	stb	,u
	leax	3,x
L226:
	ldu	,x
	bne	L227
	ldx	#LC32
	jsr	_ColdPrint
	ldb	#-120
	stb	-112
	clr	-111
	ldx	#LC33
	jsr	_ColdPrint
	ldx	#LC34
	jsr	_ColdPrint
	ldd	#8
	std	,--s
	ldx	#280
	stx	,--s
	ldx	#24
	jsr	_memcpy
	ldx	#LC35
	jsr	_ColdPrint
	clr	_gKern+6
	clr	_gKern+4
	clr	_gKern+7
	ldb	#1
	stb	_gKern+5
	ldx	#LC36
	jsr	_ColdPrint
	jsr	_NowSwitchToChatScreen
	ldx	#LC37
	jsr	_ColdPrint
	ldx	#_StrNekotOS
	jsr	_ColdPrint
	ldb	#67
	stb	1037
	ldb	#75
	stb	1041
	ldb	#81
	stb	1045
	ldb	#66
	stb	1053
	ldb	#-4
	jsr	_bSendControl
	ldb	#66
	jsr	_PutChar
	ldb	#78
	jsr	_PutChar
	ldb	#110
	stb	12,s
	ldb	#101
	stb	13,s
	ldb	#107
	stb	14,s
	ldb	#111
	stb	15,s
	ldb	#116
	stb	16,s
	ldb	#49
	stb	17,s
	clr	18,s
	clr	19,s
	ldb	#4
	stb	20,s
	clr	21,s
	clr	22,s
	ldb	#8
	stb	23,s
	ldd	#_gScore
	tfr	a,b
	clra		;zero_extendqihi: R:b -> R:d
	stb	24,s	;movlsbqihi: R:d -> 24,s
	ldd	#_gScore
	stb	25,s	;movlsbqihi: R:d -> 25,s
	ldd	#_gWall
	tfr	a,b
	clra		;zero_extendqihi: R:b -> R:d
	stb	26,s	;movlsbqihi: R:d -> 26,s
	ldd	#_gWall
	stb	27,s	;movlsbqihi: R:d -> 27,s
	ldb	#91
	jsr	_PutChar
	leau	12,s
	leax	,u
	jsr	_PutStr
	ldb	#16
	stb	,-s
	pshs	u
	ldx	#1
	ldb	#64
	jsr	_SendPacket
	ldb	#72
	jsr	_PutChar
	ldb	#8
	stb	,-s
	ldx	#280
	stx	,--s
	ldx	#2
	ldb	#64
	jsr	_SendPacket
	leas	10,s
	ldb	#93
	jsr	_PutChar
	ldb	#53
	stb	-253
	ldx	#_StrReady
	jsr	_ColdPrint
	ldx	#3000
	jsr	_Delay
	jsr	_embark
	ldd	#0
	std	,--s
	ldx	#LC38
	jsr	_gFatal
	ldx	#0
	leas	26,s
	puls	y,u,pc

	.area	.bss
_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	_memset
	.word	_memcpy
	.word	_memset_words
	.word	_memcpy_words
	.word	_strlen
	.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	12
_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
_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
_StrNekotOS:
	.ascii "NEKOTOS ... \0"
_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	-274
	.word	-271
	.word	-268
	.word	-265
	.word	-262
	.word	-259
_gime_reset_sequence:
	.word	-112
	.byte	-52
	.word	-111
	.byte	0
	.word	-110
	.byte	0
	.word	-109
	.byte	0
	.word	-108
	.byte	-1
	.word	-107
	.byte	-1
	.word	-106
	.byte	0
	.word	-105
	.byte	0
	.word	-104
	.byte	0
	.word	-103
	.byte	0
	.word	-102
	.byte	0
	.word	-101
	.byte	0
	.word	-100
	.byte	15
	.word	-99
	.byte	-32
	.word	-98
	.byte	0
	.word	-97
	.byte	0
	.word	-96
	.byte	56
	.word	-95
	.byte	57
	.word	-94
	.byte	58
	.word	-93
	.byte	59
	.word	-92
	.byte	60
	.word	-91
	.byte	61
	.word	-90
	.byte	62
	.word	-89
	.byte	63
	.word	-88
	.byte	56
	.word	-87
	.byte	48
	.word	-86
	.byte	49
	.word	-85
	.byte	50
	.word	-84
	.byte	51
	.word	-83
	.byte	61
	.word	-82
	.byte	53
	.word	-81
	.byte	63
	.word	-80
	.byte	18
	.word	-79
	.byte	36
	.word	-78
	.byte	11
	.word	-77
	.byte	7
	.word	-76
	.byte	63
	.word	-75
	.byte	31
	.word	-74
	.byte	9
	.word	-73
	.byte	38
	.word	-72
	.byte	0
	.word	-71
	.byte	18
	.word	-70
	.byte	0
	.word	-69
	.byte	63
	.word	-68
	.byte	0
	.word	-67
	.byte	18
	.word	-66
	.byte	0
	.word	-65
	.byte	38
	.word	0
	zmb	1	;skip space
_StrReady:
	.ascii " READY\0"

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

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

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

	.area	.data
_gConfig:
	.word	16384
	.word	LC39
