No i rzeczony Mt Everest kompilatorstwa - otworzenie ramki w Wolinie, rzecz według niejakiego Sajmosi - niemożliwa. Tak wygląda program:
package pl.qus.wolin
// raster interrupt colour band taken from:
// https://gist.github.com/bremensaki/8f33cd7d67b78377881c7eb7147c0f32
var interruptRoutineVector: uword^0x314 // this is C64 raster interrupt vector
var cia1InerruptCtrlReg: ubyte^0xDC0D
var vicScreenCtrlReg1: ubyte^0xD011
var vicRasterLine: ubyte^0xD012
var vicInterruptStatusReg: ubyte^0xd019
var vicInterruptCtrlReg: ubyte^0xd01a
var vicBorder: ubyte^53280
var vicBackground: ubyte^53281
var i: ubyte
var maskInterrupts: bool^CPU.I
var spritesOn: ubyte^0xd015
var sprite0X: ubyte^0xd000
var sprite0Y: ubyte^0xd001
var spritesFat: ubyte^0xd01d
var spritesTall: ubyte^0xd017
var sprite0Color: ubyte^0xd027
var sprite0Pointer: ubyte^2040
var spriteData: ubyte[ubyte]
var realSprite: ubyte[ubyte]^12288
fun clearScreen^0xe544()
fun onRasterGoto(line: ubyte, proc: uword) {
interruptRoutineVector = proc
vicRasterLine = line
}
/*********************************************************
* Raster bar
**********************************************************/
interrupt fun backgroundToBlue() {
onRasterGoto(140, backgroundToWhite)
vicBorder = 6
vicBackground = 6
vicInterruptStatusReg = 0xff
return@0xea31
}
interrupt fun backgroundToWhite() {
onRasterGoto(160, backgroundToBlue)
vicBorder = 1
vicBackground = 1
vicInterruptStatusReg = 0xff
return@0xea31
}
fun rasterBar() {
vicBorder = 6 // Init screen and border to blue
vicBackground = 6
vicInterruptCtrlReg := 1 // Enable raster interrupts
vicScreenCtrlReg1 .= 128 // High bit of raster line cleared, we're only working within single byte ranges
onRasterGoto(140, backgroundToBlue)
}
/*********************************************************
* Open border
**********************************************************/
interrupt fun topRoutine() {
vicScreenCtrlReg1 := 8 // 25 rows
onRasterGoto(0xf9, bottomRoutine)
vicInterruptStatusReg = 0xff
return@0xea31
}
interrupt fun bottomRoutine() {
vicScreenCtrlReg1 .= 8 // 24 rows
onRasterGoto(0xff, topRoutine)
vicInterruptStatusReg = 0xff // at line ff set to 25 rows
return@0xea31
}
fun openBorder() {
spritesOn := 1
spritesFat := 1
spritesTall := 1
sprite0X = 100
sprite0Y = 30
sprite0Color = 2
sprite0Pointer = 192
vicBackground = 0
i = 0
do {
realSprite[i] = spriteData[i]
i++
} while (i<64)
vicInterruptCtrlReg := 1 // Enable raster interrupts
vicScreenCtrlReg1 .= 128 // High bit of raster line cleared, we're only working within single byte ranges
onRasterGoto(0xf9, bottomRoutine)
}
/*********************************************************
* Main function
**********************************************************/
fun main() {
//clearScreen()
maskInterrupts = true // Suspend interrupts during init
cia1InerruptCtrlReg = 0x7f // Disable CIA
//rasterBar()
openBorder()
maskInterrupts = false // Enable interrupts again
do {
i++
} while (i<255) // Eternal do-nothing loop, we're done.
}
Tak wygląda wyprodukowany przez niego kod assemblera (z jednym oszustwem - bajty duszka wpisałem ręcznie, jako że mój język nie posiada jeszcze inicjalizatorów tablic)
; setupHEADER
;**********************************************
;*
;* BASIC header
;*
;* compile with:
;* cl65.exe -o assembler.prg -t c64 -C c64-asm.cfg -g -Ln labels.txt assembler.s
;*
;**********************************************
.org 2049
.export LOADADDR = *
Bas10: .word BasEnd
.word 10
.byte 158 ; sys
.byte " 2064"
.byte 0
BasEnd: .word 0
.word 0
;
; setupSPF=251[ubyte],40959[uword]
; prepare function stack
__wolin_spf := 251 ; function stack ptr
__wolin_spf_hi := 251+1 ; function stack ptr
__wolin_spf_top := 40959 ; function stack top
__wolin_spf_top_hi := 40959+1 ; function stack top
lda #<__wolin_spf_top ; set function stack top
sta __wolin_spf
lda #>__wolin_spf_top
sta __wolin_spf+1
; setupSP=114[ubyte]
; prepare program stack
__wolin_sp_top := 114 ; program stack top
__wolin_sp_top_hi := 114+1 ; program stack top
ldx #__wolin_sp_top ; set program stack top
; setupHEAP=176[ubyte]
__wolin_this_ptr := 176
__wolin_this_ptr_hi := 176+1
; allocSPF,#0
; call__wolin_pl_qus_wolin_main[adr]
jsr __wolin_pl_qus_wolin_main
; ret
rts
; function__wolin_pl_qus_wolin_onRasterGoto
__wolin_pl_qus_wolin_onRasterGoto:
; let788[uword]=SPF(0)<pl.qus.wolin.onRasterGoto.proc>[uword]
ldy #0
lda (__wolin_spf),y
sta 788
iny
lda (__wolin_spf),y
sta 788+1
; let53266[ubyte]=SPF(2)<pl.qus.wolin.onRasterGoto.line>[ubyte]
ldy #2
lda (__wolin_spf),y
sta 53266
; freeSPF<pl.qus.wolin.onRasterGoto.__fnargs>,#3
clc
lda __wolin_spf
adc #3
sta __wolin_spf
bcc :+
inc __wolin_spf+1
:
; ret
rts
; function__wolin_pl_qus_wolin_backgroundToBlue
__wolin_pl_qus_wolin_backgroundToBlue:
; allocSPF,#3
clc
lda __wolin_spf
sbc #3
sta __wolin_spf
bcs :+
dec __wolin_spf+1
:
; letSPF(2)[ubyte]=#140[ubyte]
ldy #2
lda #140
sta (__wolin_spf),y
; letSPF(0)[uword]=#__wolin_pl_qus_wolin_backgroundToWhite[uword]
ldy #0
lda #<__wolin_pl_qus_wolin_backgroundToWhite
sta (__wolin_spf),y
iny
lda #>__wolin_pl_qus_wolin_backgroundToWhite
sta (__wolin_spf),y
; call__wolin_pl_qus_wolin_onRasterGoto[adr]
jsr __wolin_pl_qus_wolin_onRasterGoto
; let53280[ubyte]=#6[ubyte]
lda #6
sta 53280
; let53281[ubyte]=#6[ubyte]
lda #6
sta 53281
; let53273[ubyte]=#255[ubyte]
lda #255
sta 53273
; goto59953[adr]
jmp 59953
; function__wolin_pl_qus_wolin_backgroundToWhite
__wolin_pl_qus_wolin_backgroundToWhite:
; allocSPF,#3
clc
lda __wolin_spf
sbc #3
sta __wolin_spf
bcs :+
dec __wolin_spf+1
:
; letSPF(2)[ubyte]=#160[ubyte]
ldy #2
lda #160
sta (__wolin_spf),y
; letSPF(0)[uword]=#__wolin_pl_qus_wolin_backgroundToBlue[uword]
ldy #0
lda #<__wolin_pl_qus_wolin_backgroundToBlue
sta (__wolin_spf),y
iny
lda #>__wolin_pl_qus_wolin_backgroundToBlue
sta (__wolin_spf),y
; call__wolin_pl_qus_wolin_onRasterGoto[adr]
jsr __wolin_pl_qus_wolin_onRasterGoto
; let53280[ubyte]=#1[ubyte]
lda #1
sta 53280
; let53281[ubyte]=#1[ubyte]
lda #1
sta 53281
; let53273[ubyte]=#255[ubyte]
lda #255
sta 53273
; goto59953[adr]
jmp 59953
; function__wolin_pl_qus_wolin_rasterBar
__wolin_pl_qus_wolin_rasterBar:
; let53280[ubyte]=#6[ubyte]
lda #6
sta 53280
; let53281[ubyte]=#6[ubyte]
lda #6
sta 53281
; bit53274[ubyte]=#1[ubyte],#1[bool]
lda 53274
ora #1
sta 53274
; bit53265[ubyte]=#128[ubyte],#0[bool]
lda 53265
and #$ff-128
sta 53265
; allocSPF,#3
clc
lda __wolin_spf
sbc #3
sta __wolin_spf
bcs :+
dec __wolin_spf+1
:
; letSPF(2)[ubyte]=#140[ubyte]
ldy #2
lda #140
sta (__wolin_spf),y
; letSPF(0)[uword]=#__wolin_pl_qus_wolin_backgroundToBlue[uword]
ldy #0
lda #<__wolin_pl_qus_wolin_backgroundToBlue
sta (__wolin_spf),y
iny
lda #>__wolin_pl_qus_wolin_backgroundToBlue
sta (__wolin_spf),y
; call__wolin_pl_qus_wolin_onRasterGoto[adr]
jsr __wolin_pl_qus_wolin_onRasterGoto
; ret
rts
; function__wolin_pl_qus_wolin_topRoutine
__wolin_pl_qus_wolin_topRoutine:
; bit53265[ubyte]=#8[ubyte],#1[bool]
lda 53265
ora #8
sta 53265
; allocSPF,#3
clc
lda __wolin_spf
sbc #3
sta __wolin_spf
bcs :+
dec __wolin_spf+1
:
; letSPF(2)[ubyte]=#249[ubyte]
ldy #2
lda #249
sta (__wolin_spf),y
; letSPF(0)[uword]=#__wolin_pl_qus_wolin_bottomRoutine[uword]
ldy #0
lda #<__wolin_pl_qus_wolin_bottomRoutine
sta (__wolin_spf),y
iny
lda #>__wolin_pl_qus_wolin_bottomRoutine
sta (__wolin_spf),y
; call__wolin_pl_qus_wolin_onRasterGoto[adr]
jsr __wolin_pl_qus_wolin_onRasterGoto
; let53273[ubyte]=#255[ubyte]
lda #255
sta 53273
; goto59953[adr]
jmp 59953
; function__wolin_pl_qus_wolin_bottomRoutine
__wolin_pl_qus_wolin_bottomRoutine:
; bit53265[ubyte]=#8[ubyte],#0[bool]
lda 53265
and #$ff-8
sta 53265
; allocSPF,#3
clc
lda __wolin_spf
sbc #3
sta __wolin_spf
bcs :+
dec __wolin_spf+1
:
; letSPF(2)[ubyte]=#255[ubyte]
ldy #2
lda #255
sta (__wolin_spf),y
; letSPF(0)[uword]=#__wolin_pl_qus_wolin_topRoutine[uword]
ldy #0
lda #<__wolin_pl_qus_wolin_topRoutine
sta (__wolin_spf),y
iny
lda #>__wolin_pl_qus_wolin_topRoutine
sta (__wolin_spf),y
; call__wolin_pl_qus_wolin_onRasterGoto[adr]
jsr __wolin_pl_qus_wolin_onRasterGoto
; let53273[ubyte]=#255[ubyte]
lda #255
sta 53273
; goto59953[adr]
jmp 59953
; function__wolin_pl_qus_wolin_openBorder
__wolin_pl_qus_wolin_openBorder:
; bit53269[ubyte]=#1[ubyte],#1[bool]
lda 53269
ora #1
sta 53269
; bit53277[ubyte]=#1[ubyte],#1[bool]
lda 53277
ora #1
sta 53277
; bit53271[ubyte]=#1[ubyte],#1[bool]
lda 53271
ora #1
sta 53271
; let53248[ubyte]=#100[ubyte]
lda #100
sta 53248
; let53249[ubyte]=#30[ubyte]
lda #30
sta 53249
; let53287[ubyte]=#2[ubyte]
lda #2
sta 53287
; let2040[ubyte]=#192[ubyte]
lda #192
sta 2040
; let53281[ubyte]=#0[ubyte]
lda #0
sta 53281
; let__wolin_pl_qus_wolin_i<pl.qus.wolin.i>[ubyte]=#0[ubyte]
lda #0
sta __wolin_pl_qus_wolin_i
; allocSP<__wolin_reg101>,#1
dex
; label__wolin_lab_loopStart_1
__wolin_lab_loopStart_1:
; allocSP<__wolin_reg104>,#2
dex
dex
; addSP(0)<__wolin_reg104>[ubyte*]=12288[ubyte*],__wolin_pl_qus_wolin_i<pl.qus.wolin.i>[ubyte]
clc
lda #<12288
adc __wolin_pl_qus_wolin_i
sta 0,x
lda #>12288
adc #0
sta 0+1,x
; allocSP<__wolin_reg106>,#2
dex
dex
; addSP(0)<__wolin_reg106>[ubyte*]=__wolin_pl_qus_wolin_spriteData[ubyte*],__wolin_pl_qus_wolin_i<pl.qus.wolin.i>[ubyte]
clc
lda #<__wolin_pl_qus_wolin_spriteData
adc __wolin_pl_qus_wolin_i
sta 0,x
lda #>__wolin_pl_qus_wolin_spriteData
adc #0
sta 0+1,x
; let&SP(2)<__wolin_reg104>[ubyte*]=&SP(0)<__wolin_reg106>[ubyte*]
lda (0,x)
sta (2,x)
; freeSP<__wolin_reg106>,#2
inx
inx
; freeSP<__wolin_reg104>,#2
inx
inx
; add__wolin_pl_qus_wolin_i<pl.qus.wolin.i>[ubyte]=__wolin_pl_qus_wolin_i<pl.qus.wolin.i>[ubyte],#1[ubyte]
inc __wolin_pl_qus_wolin_i
; evallessSP(0)<__wolin_reg101>[bool]=__wolin_pl_qus_wolin_i<pl.qus.wolin.i>[ubyte],#64[ubyte]
lda #1 ; mniejsze
sta 0,x
lda __wolin_pl_qus_wolin_i
cmp #64
bcc :+
lda #0 ; jednak wieksze
sta 0,x
:
; beqSP(0)<__wolin_reg101>[bool]=#1[bool],__wolin_lab_loopStart_1<label_po_if>[uword]
lda 0,x
bne __wolin_lab_loopStart_1
; label__wolin_lab_loopEnd_1
__wolin_lab_loopEnd_1:
; freeSP<__wolin_reg101>,#1
inx
; bit53274[ubyte]=#1[ubyte],#1[bool]
lda 53274
ora #1
sta 53274
; bit53265[ubyte]=#128[ubyte],#0[bool]
lda 53265
and #$ff-128
sta 53265
; allocSPF,#3
clc
lda __wolin_spf
sbc #3
sta __wolin_spf
bcs :+
dec __wolin_spf+1
:
; letSPF(2)[ubyte]=#249[ubyte]
ldy #2
lda #249
sta (__wolin_spf),y
; letSPF(0)[uword]=#__wolin_pl_qus_wolin_bottomRoutine[uword]
ldy #0
lda #<__wolin_pl_qus_wolin_bottomRoutine
sta (__wolin_spf),y
iny
lda #>__wolin_pl_qus_wolin_bottomRoutine
sta (__wolin_spf),y
; call__wolin_pl_qus_wolin_onRasterGoto[adr]
jsr __wolin_pl_qus_wolin_onRasterGoto
; ret
rts
; function__wolin_pl_qus_wolin_main
__wolin_pl_qus_wolin_main:
; letCPU.I[bool]=#1[bool]
sei
; let56333[ubyte]=#127[ubyte]
lda #127
sta 56333
; allocSPF,#0
; call__wolin_pl_qus_wolin_openBorder[adr]
jsr __wolin_pl_qus_wolin_openBorder
; letCPU.I[bool]=#0[bool]
cli
; allocSP<__wolin_reg131>,#1
dex
; label__wolin_lab_loopStart_2
__wolin_lab_loopStart_2:
; add__wolin_pl_qus_wolin_i<pl.qus.wolin.i>[ubyte]=__wolin_pl_qus_wolin_i<pl.qus.wolin.i>[ubyte],#1[ubyte]
inc __wolin_pl_qus_wolin_i
; evallessSP(0)<__wolin_reg131>[bool]=__wolin_pl_qus_wolin_i<pl.qus.wolin.i>[ubyte],#255[ubyte]
lda #1 ; mniejsze
sta 0,x
lda __wolin_pl_qus_wolin_i
cmp #255
bcc :+
lda #0 ; jednak wieksze
sta 0,x
:
; beqSP(0)<__wolin_reg131>[bool]=#1[bool],__wolin_lab_loopStart_2<label_po_if>[uword]
lda 0,x
bne __wolin_lab_loopStart_2
; label__wolin_lab_loopEnd_2
__wolin_lab_loopEnd_2:
; freeSP<__wolin_reg131>,#1
inx
; ret
rts
; label__wolin_indirect_jsr
__wolin_indirect_jsr:
; goto65535[adr]
jmp 65535
; label__wolin_pl_qus_wolin_spriteData
__wolin_pl_qus_wolin_spriteData:
; alloc0[ubyte*]
.byte $ee,$51,$23,$8a,$5b,$54,$ee,$55
.byte $52,$2a,$51,$51,$ea,$d1,$26,$00
.byte $00,$00,$b8,$00,$00,$a8,$00,$00
.byte $b8,$00,$00,$a8,$00,$00,$a8,$00
.byte $00,$00,$00,$00,$ea,$a4,$00,$8a
.byte $a4,$00,$8e,$a4,$00,$8a,$a4,$00
.byte $ea,$4c,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$03
; label__wolin_pl_qus_wolin_i
__wolin_pl_qus_wolin_i:
; alloc0[ubyte]
.byte 0
Oraz w załaczniku gotowy program. Jeżeli okaże się, że ramki da się otworzyć w języku wysokiego poziomu, to Waszym oczom powinien ukazać się duszek-niespodzianka w dowcipny sposób kwitujący całą dyskusję.