Skip to content

Instantly share code, notes, and snippets.

@fesh0r
Created July 13, 2021 08:20
Show Gist options
  • Save fesh0r/b1d2061e86703c281deff9f0d5326244 to your computer and use it in GitHub Desktop.
Save fesh0r/b1d2061e86703c281deff9f0d5326244 to your computer and use it in GitHub Desktop.
\ Doom Fire!
\ beebasm.exe -w -v -i fire_master.asm -do fire.ssd -boot fire
OSRDCH = &FFE0
OSWRCH = &FFEE
OSWORD = &FFF1
OSBYTE = &FFF4
OSCLI = &FFF7
CRTC_REG = &FE00
CRTC_VAL = &FE01
VIDPROC_CTL = &FE20
VIDPROC_PAL = &FE21
SVIA = &FE40
SVIA_IFR = SVIA+13
SVIA_IER = SVIA+14
UVIA = &FE60
UVIA_IFR = UVIA+13
UVIA_IER = UVIA+14
IRQ1V = &204
os_VIDPROC_CTL = &248
vsyncCtr = &240
coloursL = &70
coloursR = &80
buffPtr = &7E
buffCnt = &8E
randLo = &7D
randHi = &8D
dispX = &7F
width = 40
height = 32
buffer = &3000
buffer_len = width*height
display = &7C00+&180-4
seed = &BEEB
basic = FALSE
ORG &1C00
.start
IF basic
EQUB &0D,&00,&0A,&F9,&D6,&90,&3A,&F4,&00
ENDIF
LDA #22
JSR OSWRCH
LDA #2
JSR OSWRCH
LDA #&E0
STA os_VIDPROC_CTL
LDX #14
.crtc_loop
LDA crtc_config,X
STX CRTC_REG
STA CRTC_VAL
LDA coloursSrc,X
AND #&FE
STA coloursL,X
LSR A
STA coloursR,X
DEX
BPL crtc_loop
LDX #width-1
LDA #12
.init_loop
STA buffer+buffer_len,X
DEX
BPL init_loop
LDA #LO(seed)
STA randLo
LDA #HI(seed)
STA randHi
LDA #LO(buffer-1)
STA buffPtr
LDA #LO(buffer_len)
STA buffCnt
.main_loop
LDA #HI(buffer-1)
STA buffPtr+1
LDA #HI(buffer_len)
STA buffCnt+1
.calc_loop
LDA randHi
LSR A
ROR randLo
BCC skip_eor
EOR #&B4
.skip_eor
STA randHi
LDY #width+1
LDA (buffPtr),Y
BEQ already_zero
SBC #0
.already_zero
LDY #1
BIT randLo
BPL do_store
DEY
BVS do_store
INY
INY
.do_store
STA (buffPtr),Y
INC buffPtr
BNE skip_buff
INC buffPtr+1
.skip_buff
DEC buffCnt
BNE calc_loop
DEC buffCnt+1
BNE calc_loop
LDA #19
JSR OSBYTE
LDY #0
STY dispX
.disp_loop
LDX buffer+&0000,Y
LDA coloursL,X
LDX buffer+&0001,Y
ORA coloursR,X
LDX dispX
STA display+&0000,X
LDX buffer+&0100,Y
LDA coloursL,X
LDX buffer+&0101,Y
ORA coloursR,X
LDX dispX
STA display+&0080,X
LDX buffer+&0200,Y
LDA coloursL,X
LDX buffer+&0201,Y
ORA coloursR,X
LDX dispX
STA display+&0100,X
LDX buffer+&0300,Y
LDA coloursL,X
LDX buffer+&0301,Y
ORA coloursR,X
LDX dispX
STA display+&0180,X
LDX buffer+&0400,Y
LDA coloursL,X
LDX buffer+&0401,Y
ORA coloursR,X
LDX dispX
STA display+&0200,X
INC dispX
INY
INY
BNE disp_loop
JMP main_loop
.coloursSrc
EQUB &00+1 \ black
EQUB &20+1 \ blue
EQUB &22+1 \ magenta
EQUB &22+1 \ magenta
EQUB &22+1 \ magenta
EQUB &02+1 \ red
EQUB &02+1 \ red
EQUB &02+1 \ red
EQUB &02+1 \ red
EQUB &0A+1 \ yellow
EQUB &0A+1 \ yellow
EQUB &0A+1 \ yellow
EQUB &2A+1 \ white
.crtc_config
EQUB 63 \ R0 Horizontal total
EQUB 20 \ R1 Characters per line
EQUB 39 \ R2 Horizontal sync position
EQUB &24 \ R3 Sync length
EQUB 77 \ R4 Vertical total
EQUB 0 \ R5 Vertical total adjust
EQUB 51 \ R6 Vertical displayed characters
EQUB 60 \ R7 Vertical sync position
EQUB &00 \ R8 Interlace and delay
EQUB 3 \ R9 Scan lines per character
EQUB &20 \ R10 Cursor start and type
EQUB 0 \ R11 Cursor end
EQUB &28 \ R12 Screen start high
EQUB &00 \ R13 Screen start low
IF basic
EQUB &00, &0D, &FF
ENDIF
.end
PRINT "Size: ", end-start
SAVE "fire", start, end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment