incsrc CoinDefines.asm
org !SSM16space
SubSetMap16Main:


db "STAR"
dw Ratlabel1-Ratlabel2-$01
dw Ratlabel1-Ratlabel2-$01^$FFFF
Ratlabel2:
PHP
REP #$30
PHY
PHX
TAX
LDA $03
PHA
JSL .Sub8034
PLA
STA $03
PLX
PLY
PLP
RTL

.Return18
PLX
PLB
PLP
RTL

.Sub8034
PHP
SEP #$20
PHB
LDA #$00
PHA
PLB
REP #$30
PHX
LDA $9A
STA $0C
LDA $98
STA $0E
LDA.w #$0000
SEP #$20
LDA $5B
STA $09
LDA $1933
BEQ .NoShift
LSR $09
.NoShift
LDY $0E
LDA $09
AND #$01
BEQ .Horiz
LDA $9B
STA $00
LDA $99
STA $9B
LDA $00  
STA $99
LDY $0C
.Horiz
CPY #$0200
BCS .Return18
LDA $1933
ASL
TAX
LDA $BEA8,x
STA $65
LDA $BEA9,x
STA $66
STZ $67
LDA $1925
ASL
TAY
LDA ($65),y
STA $04
INY
LDA ($65),y
STA $05
STZ $06
LDA $9B
STA $07
ASL
CLC
ADC $07
TAY
LDA ($04),y
STA $6B
STA $6E
INY
LDA ($04),y
STA $6C
STA $6F
LDA #$7E
STA $6D
INC
STA $70
LDA $09
AND #$01
BEQ .NoAnd
LDA $99
LSR
LDA $9B
AND #$01
BRA .Label52
.NoAnd
LDA $9B
LSR
LDA $99
.Label52
ROL
ASL #2
ORA #$20
STA $04
CPX.w #$0000
BEQ .NoAdd
CLC
ADC #$10 
STA $04
.NoAdd
LDA $98
AND #$F0
CLC
ASL
ROL
STA $05
ROL
AND #$03
ORA $04
STA $06
LDA $9A
AND #$F0
LSR #3
STA $04
LDA $05
AND #$C0
ORA $04
STA $07
REP #$20
LDA $09
AND.w #$0001
BNE .Label51
LDA $1A
SEC
SBC.w #$0080
TAX
LDY $1C
LDA $1933
BEQ .Label50
LDX $1E
LDA $20
SEC
SBC.w #$0080
TAY
BRA .Label50
.Label51
LDX $1A
LDA $1C
SEC
SBC.w #$0080
TAY
LDA $1933
BEQ .Label50
LDA $1E
SEC
SBC.w #$0080
TAX  
LDY $20
.Label50
STX $08
STY $0A
LDA $98
AND #$01F0
STA $04
LDA $9A
LSR #4
AND.w #$000F
ORA $04
TAY
PLA
SEP #$20
STA [$6B],y
XBA
STA [$6E],y
XBA
REP #$20
ASL A
TAY
PHK
PEA.w .Map16Return-$01
PEA $804C
JML $00C0FB|$800000
.Map16Return
PLB
PLP
RTL

Ratlabel1: