6502_linux_logo/linuxlogo.s

398 lines
12 KiB
ArmAsm
Raw Normal View History

2017-07-17 07:52:37 +00:00
; 6502 Linux Logo
; Michaelangel007
; https://github.com/Michaelangel007/6502_linux_logo
; Zero Page ROM vars
zCursorX = $24 ; CH
zCursorY = $25 ; CH
2017-07-18 18:51:38 +00:00
zHgrPtr = $26 ; GBASL = Dst Pixel Addr
2017-07-17 07:52:37 +00:00
zTxtPtr = $28 ; BASL = Dst
2017-07-18 18:51:38 +00:00
zDstOffset = $F9 ; dst
zSrcOffset = $FA ; src
zMask = $FB ; adjacent byte to write next pixels
zSrcShift = $FC ; Input Bit Position = i mod 8
zDstShift = $FD ; Output Bit Position = i mod 7
2017-07-17 07:52:37 +00:00
zUnpackBits = $FE ; 16-bit unpack
; ROM
HOME = $FC58
IB_HGR = $D000 ; Integer BASIC ][ only
AS_HGR = $F3E2 ; Applesoft BASIC ][+ or newer
2017-07-18 18:51:38 +00:00
BASCALC = $FBC1 ; A=Row, Calculate BASL,BASH text start-of-line address
2017-07-17 07:52:37 +00:00
;Bank Addr -- Addr Bank Read --- Write -------
; 2 $C080 == $C088 1 Read RAM Write protect
; 2 $C081 == $C089 1 Read ROM Write enabled
; 2 $C082 == $C08A 1 Read ROM Write protect
; 2 $C083 == $C08B 1 Read RAM Write enabled
RAMIN = $C080
ROMIN = $C081
MACHINEID1 = $FBB3
MACHINEID2 = $FBC0
MACHINEID3 = $FBBF ; //c version
; Config
2017-07-18 18:51:38 +00:00
UnpackAddr = $3FD0 ; Y=191, Unpacked pixel buffer of $28 bytes
2017-07-17 07:52:37 +00:00
CONFIG_PROBE_CPUINFO = 1
CONFIG_PRINT_CPUINFO = 1
; ========================================================================
ORG $900
Main
jsr HOME
; ------------------------------------------------------------------------
; Apple II Technical Note #7
; https://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Computers/Apple%20II/Apple%20II/Documentation/Misc%20%23007%20Apple%20II%20Family%20ID.pdf
;
; Machine $FBB3 $FBC0 $FBBE
; Apple ][ $38
; Apple ][+ $EA
; Apple /// $EA
; Apple //e $06 $EA
; Apple //e+ $06 $E0
; Apple //e Option Card $06 $E0
; Apple //c $06 $00 $FF
; Apple //c 3.5 $06 $00 $00
; Apple //c Org Mem XP $06 $00 $03
; Apple //c Rev Mem XP $06 $00 $04
; Apple //c+ $06 $00 $05
; Apple IIgs
DO CONFIG_PROBE_CPUINFO
detect_model
2017-07-17 07:52:37 +00:00
lda MACHINEID1 ; FBB3: $38 = ][, $EA = ][+, $06 = //e //c IIgs
2017-07-19 17:04:17 +00:00
cmp #$38 ; '8'
2017-07-19 17:12:09 +00:00
beq apple_ii
2017-07-17 07:52:37 +00:00
apple_iiplus
2017-07-19 17:02:10 +00:00
pha
2017-07-19 17:06:03 +00:00
jsr AS_HGR ; HGR on Apple ][+ or newer
2017-07-17 07:52:37 +00:00
pla
2017-07-19 17:04:17 +00:00
cmp #$EA ; 'j' apple ][+?
2017-07-19 17:09:14 +00:00
bne apple_iie_iic ; if so keep going
2017-07-17 07:52:37 +00:00
lda #"+"
bne set_apple_ii
; if we get here we're a ii+ or iii in emulation mode
2017-07-19 17:12:09 +00:00
apple_ii
jsr IB_HGR ; HGR on original ][ only!
lda #" " ; "_6502"
2017-07-17 07:52:37 +00:00
set_apple_ii
2017-07-17 19:22:54 +00:00
ldx #"]"
ldy #"["
stx ModType-2
sty ModType-1
2017-07-17 07:52:37 +00:00
sta ModType ; erase last 'e' in 'Apple IIe'
2017-07-18 18:56:03 +00:00
lda #" " ; "_6502"
sta CpuType ; ^^^
2017-07-17 19:22:54 +00:00
ldx #"6"
ldy #"5"
stx CpuType+1
sty CpuType+2
2017-07-17 07:52:37 +00:00
detect_langcard
sta RAMIN ; Detect 16K RAM / Language Card
sta RAMIN ; Read RAM
lda $D000
eor #$FF
sta $D000
cmp $D000
bne apple_ii_48K
eor #$FF
sta $D000
RAM_64K
2017-07-19 17:12:09 +00:00
ldx #"6" ; "64K"
2017-07-17 07:52:37 +00:00
ldy #"4"
bne RAM_size
apple_ii_48K
ldx #"4"
ldy #"8"
RAM_size
lda #" "
sta RamSize ; erase '1' in '128'
stx RamSize+1
sty RamSize+2
bne done_detecting
; Detect //e //e+ //c
2017-07-19 17:09:14 +00:00
apple_iie_iic
2017-07-17 07:52:37 +00:00
lda MACHINEID2 ; FBC0: $00 = //c, $EA = //e, E0 = //e+
beq apple_iic ; check for apple //c
cmp #$E0 ; if we're an Apple IIe (original)
bne RAM_64K ; then use 64K and finish
beq apple_iie_enhanced
apple_iic
lda #"c"
sta CpuType+1
lda MACHINEID3
cmp #$05 ; //c+
bne done_detecting
apple_iie_enhanced ; //c+
ldx #1 ; //e+
jsr ModelPlus ; ^
done_detecting
sta ROMIN ; Turn off Language Card
2017-07-19 17:12:09 +00:00
; sta ROMIN ; if it was probed
2017-07-17 07:52:37 +00:00
FIN
; ------------------------------------------------------------------------
; Unpack 2 bits/color -> $28 bytes/scanline
;
2017-07-18 03:43:51 +00:00
; Unpack one line to buffer at Y=191 HGR line
2017-07-17 07:52:37 +00:00
; Copy to 8 scanlines
2017-07-18 03:43:51 +00:00
; Erase buffer after copying to final 8 scanlines
2017-07-17 07:52:37 +00:00
Unpack
DO 1-CONFIG_PROBE_CPUINFO
jsr AS_HGR ; *** DEBUG ***
FIN
2017-07-18 03:12:41 +00:00
lda #7 ; will INC, $0428 (Text) + $1C00 => $2028 (HGR)
sta zCursorY ; Start Row=8
2017-07-19 16:16:13 +00:00
ldy #0 ; zSrcOffset
sty zDstShift
sty zDstOffset
2017-07-17 07:52:37 +00:00
lda PackedBits
sta zUnpackBits+0
NextSrcShift
lda PackedBits+1,Y
sta zUnpackBits+1
2017-07-19 16:16:13 +00:00
ldx #0 ; zSrcShift
2017-07-17 19:22:54 +00:00
UpdateSrcShift
2017-07-18 03:12:41 +00:00
stx zSrcShift
2017-07-17 19:22:54 +00:00
2017-07-17 07:52:37 +00:00
jsr Unpack2Bits ; hhggffee C=? ddccbbaa
2017-07-18 18:51:38 +00:00
bcs UnpackDone ; inlining Unpack2Bits has BNE and BNE > 128 byte offset
2017-07-17 19:22:54 +00:00
2017-07-17 07:52:37 +00:00
lsr zUnpackBits+1 ; 0hhggffe C=e ddccbbaa
ror zUnpackBits+0 ; 0hhggffe C=e eddccbba
lsr zUnpackBits+1 ; 00hhggff C=e eddccbba
ror zUnpackBits+0 ; 00hhggff c=e eeddccbb
2017-07-17 19:22:54 +00:00
2017-07-18 03:12:41 +00:00
ldx zSrcShift
inx
inx
cpx #8 ; have 8 input bits?
2017-07-17 19:22:54 +00:00
bne UpdateSrcShift
2017-07-17 07:52:37 +00:00
iny ; src++
2017-07-18 03:12:41 +00:00
bne NextSrcShift ; always, since packed data length < 256
2017-07-17 07:52:37 +00:00
UnpackDone
; ------------------------------------------------------------------------
DO CONFIG_PRINT_CPUINFO
2017-07-18 03:40:19 +00:00
txa ; (2) X=$14 from (1) Unpack2Bits
2017-07-18 18:51:38 +00:00
ldx #0 ; This means we have an extra "row" of HGR garbage at Y=160
PrintText ; but we can't see it since we are in mixed mode
2017-07-18 03:12:41 +00:00
jsr BASCALC
2017-07-17 07:52:37 +00:00
ldy #0
CopyTextLine
lda TextLine,X
sta (zTxtPtr),Y
inx ; 3*40 = 120 chars max
iny
cpy #40
bne CopyTextLine
inc zCursorY
lda zCursorY
cmp #$17 ; Rows $14..$16 (inclusive)
bne PrintText
dec zCursorY
2017-07-18 18:56:03 +00:00
; ------------------------------------------------------------------------
2017-07-17 07:52:37 +00:00
; End of String offse for Model
; IN: X = 0 II+
; ^
; 1 //e+
; ^
ModelPlus
lda #"+"
sta ModType,x
FIN
2017-07-18 18:51:38 +00:00
; ========================================================================
; NOTE: Normally there is
; rts
; but to save a byte we intentionally fall into Unpack2Bits in 2 locations:
;
; A) if we reach
; apple_iie_enhanced
; B) end of program
;
; This means there is an extremely rare bug of having extra garbage
; on the HGR screen for (A) under these conditions:
;
; F9:27 <- zDstOffset = column 39
; FE:0x <- non-zero value bottom 2 bits are set
;
; To trigger:
; CALL-151
; BLOAD LINUXLOGO
; F9:27
; FE:02
; 900G
; Or on two lines
; BLOAD LINUXLOGO
; F9:27 N FE:2 N 900G
; And a thin blue line will appear in the top right
; ========================================================================
2017-07-17 07:52:37 +00:00
; ------------------------------------------------------------------------
; Expand 1 pixel (2 bits) via
; Output 2 pixels (4 bits)
Unpack2Bits
2017-07-18 18:51:38 +00:00
sty zSrcOffset
2017-07-17 22:32:06 +00:00
2017-07-18 18:51:38 +00:00
lda zUnpackBits ; Double the pixel
2017-07-17 22:32:06 +00:00
asl ; A=?????ba0
asl ; A=????ba00
eor zUnpackBits ; A=????xxyy
and #%00001100 ; A=????xx00
eor zUnpackBits ; A=????baba
and #%00001111 ; A=0000baba
2017-07-17 07:52:37 +00:00
ldx #0
stx zMask
2017-07-18 18:51:38 +00:00
ldy zDstShift ; which 280 px column is next pixel writing to?
2017-07-17 07:52:37 +00:00
MakeShiftMask
2017-07-17 22:32:06 +00:00
asl ; msb of byte0 set?
2017-07-17 07:52:37 +00:00
rol zMask ; shift in to lsb of byte1
2017-07-19 16:16:13 +00:00
dey
bpl MakeShiftMask
2017-07-17 22:32:06 +00:00
sec ; MSB=1 color=blue/orange
ror
2017-07-18 03:12:41 +00:00
ldx zDstOffset
2017-07-17 07:52:37 +00:00
ora UnpackAddr,X ; do all bits that fit
sta UnpackAddr,X
2017-07-18 03:12:41 +00:00
lda zDstShift ; x={0,1,2} + 4 < 7
2017-07-19 16:16:13 +00:00
adc #4 ; C=0 from ASL ROR above
2017-07-18 03:12:41 +00:00
cmp #7 ; all bits fit into dest byte?
bcc FitSameByte
2017-07-17 07:52:37 +00:00
; Update partial next byte of dest
2017-07-18 03:12:41 +00:00
; x = x + 4 - 7
; x = x - 3
2017-07-18 18:51:38 +00:00
sbc #7 ; C=1 from "BCC else" above
2017-07-18 03:12:41 +00:00
tay ; push zDstShift
2017-07-17 07:52:37 +00:00
2017-07-18 03:12:41 +00:00
inx
stx zDstOffset
2017-07-17 07:52:37 +00:00
lda zMask
ora UnpackAddr,X
sta UnpackAddr,X
2017-07-18 03:12:41 +00:00
tya ; pop zDstShift
cpx #$28 ; C = x < 28
bcc FitSameByte ; C = x < 28
2017-07-17 07:52:37 +00:00
2017-07-17 22:32:06 +00:00
; ------------------------------------------------------------------------
; Udpate the Text Address
; Update the HGR scanline Address
2017-07-18 18:51:38 +00:00
inc zCursorY
2017-07-17 22:32:06 +00:00
lda zCursorY
jsr BASCALC
lda zTxtPtr+0 ; every 8 HGR scanline address
sta zHgrPtr+0 ; is exactly same as Text low byte
lda zTxtPtr+1
clc ; every 8 HGR scanline address
adc #$1c ; is Text Page $04 + $1C = HGR Page $20
sta zHgrPtr+1
2017-07-18 18:51:38 +00:00
2017-07-17 22:32:06 +00:00
; ------------------------------------------------------------------------
2017-07-18 18:51:38 +00:00
; Copy unpacked buffer to 8 HGR scanlines
2017-07-17 07:52:37 +00:00
ldx #7 ; Repeat each scanline 8 times
Draw8Rows
2017-07-17 22:32:06 +00:00
ldy #39 ; 280/7 = 40 bytes/scanline
2017-07-17 07:52:37 +00:00
CopyScanLine
lda UnpackAddr,Y
sta (zHgrPtr),Y
2017-07-17 09:17:24 +00:00
2017-07-17 22:32:06 +00:00
txa ; Clear source on last scanline copy
2017-07-17 09:17:24 +00:00
bne CopyNextByte
sta UnpackAddr,Y
CopyNextByte
2017-07-17 22:32:06 +00:00
dey
bpl CopyScanLine
2017-07-17 07:52:37 +00:00
clc ; y = y+1
2017-07-17 22:32:06 +00:00
lda zHgrPtr+1 ; HGR addr_y+1 = addr_y + $0400
2017-07-17 07:52:37 +00:00
adc #$04
sta zHgrPtr+1
2017-07-17 22:32:06 +00:00
2017-07-18 03:12:41 +00:00
stx zDstOffset ; X=0 last loop iteration
txa ; A=0 zDstShift
2017-07-17 07:52:37 +00:00
dex
bpl Draw8Rows
2017-07-18 03:40:19 +00:00
ldx zCursorY ; (1) X=14, see (2)
2017-07-18 03:12:41 +00:00
cpx #$14 ; Y=$40 .. $A0, Rows $8..$13 (inclusive)
FitSameByte
sta zDstShift
2017-07-18 18:51:38 +00:00
ldy zSrcOffset ; NOTE: C=0 from CMPs above
2017-07-17 07:52:37 +00:00
rts
2017-07-18 18:56:03 +00:00
; ========================================================================
2017-07-17 07:52:37 +00:00
CpuType = * + 13 + 40
RamSize = * + 30 + 40
ModType = * + 24 + 40*2
2017-07-17 19:22:54 +00:00
; Uppercase in case of Apple ][ without lowercase support
2017-07-17 07:52:37 +00:00
; 1 2 3
TextLine ;0123456789012345678901234567890123456789
ASC " LINUX VERSION 2.6.22.6, COMPILED 2007 " ; Row $14
ASC " ONE 1.02MHZ 65C02 PROCESSOR, 128KB RAM " ; Row $15
2017-07-17 19:22:54 +00:00
ASC " APPLE //e " ; Row $16
2017-07-17 07:52:37 +00:00
; ^ ^ ^
2017-07-17 19:22:54 +00:00
; CPUTYPE MOD RAM
2017-07-17 07:52:37 +00:00
; ------------------------------------------------------------------------
;"__________________________________________________________@@@@@_______"
;"_________________________________________________________@@@@@@@______"
;"______________A__________________________________________@@_@_@@______"
;"@@@@@@_______AA@_________________________________________@BBBBB@______"
;"__@@__________@________________________________________@@__BBB__@@____"
;"__@@_______AAA__@@@_@@@@___@@@____@@@__@@@@@_@@@@@____@__________@@___"
;"__@@______A__A@__@@@____@@__@@_____@@____@@___@@_____@____________@@__"
;"__@@_____A___A@__@@_____@@__@@_____@@_____@@_@@______@____________@@@_"
;"__@@________AA@__@@_____@@__@@_____@@______@@@______BB@___________@@B_"
;"__@@_____@_AA@___@@_____@@__@@_____@@_____@@_@@____BBBBB@_______@BBBBB"
;"__@@____@@_AA@_@_@@_____@@__@@@___@@@____@@___@@___BBBBBB@_____@BBBBBB"
;"@@@@@@@@@@__@@@_@@@@___@@@@___@@@@_@@@_@@@@@_@@@@@__BBBBB@@@@@@@BBBBB_"
; Char &3 Color
; @ 00 Black
; A 01 Blue
; B 10 Orange
; _ 11 White
; NOTE: Generated by ascii2hgr2bit
; ASCII: 70*12 = 840 chars
2017-07-18 03:12:41 +00:00
; Packed 2bits/2pixel: 70 chars * 2 bits/char / 8 bits/byte = 140 bits / 8 = 17.5 bytes/scanline
2017-07-17 07:52:37 +00:00
; 840 chars * 2 bits/color / 8 bits/byte = 210 bytes
PUT packedlogo.s