Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/text scroller #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions itema.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@

// import our sprite library
#import "spritelib.asm"
#import "textscroller.asm"
#import "music/music.asm"

BasicUpstart2(initialize)

// Initialize
initialize:
jsr $e544 // clear screen

lda #00 // black sceen & background
sta $d020
sta $d021

lda #$ff
sta $d000 // set x position of sprite

lda #$ff
sta $d001 // set y position of sprite

lda #%00000011 // enable sprites
sta $d015
Expand Down Expand Up @@ -42,8 +53,11 @@ initialize:
sta $07f9 // sprite #2

jsr init_spritelib
jsr initScroller // setup text scroller
jsr initMusic // setup music

jsr interrupts // setup interrupts

jsr startMusic
loop:
lda #00 // wait until the screen refreshes
!: cmp $d012
Expand All @@ -57,6 +71,29 @@ loop:

jmp loop

interrupts: sei // set up interrupt
lda #$7f
sta $dc0d // turn off the CIA interrupts
sta $dd0d
and $d011 // clear high bit of raster line
sta $d011

ldy #00 // trigger on first scan line
sty $d012

lda #<handler // load interrupt address
ldx #>handler
sta $0314
stx $0315

lda #$01 // enable raster interrupts
sta $d01a
cli
rts

handler: jsr music.play
jsr noscroll
jmp $EA81

// -- Sprite Data --------------------------------------------------------------
// Created using https://www.spritemate.com
Expand All @@ -82,4 +119,4 @@ spriteData:
.byte %00110111,%00000000,%00000000
.byte %00000101,%01111101,%00000000
.byte %00001101,%01010101,%00000000
.byte %00000011,%11011100,%00000000
.byte %00000011,%11011100,%00000000
48 changes: 24 additions & 24 deletions music/music.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@
//---------------------------------------------------------
.var music = LoadSid("Nightshift.sid") //<- Here we load the sid file

startMusic: lda #$00
initMusic: lda #$00
// sta $d020
// sta $d021
ldx #0
ldy #0
lda #music.startSong-1 //<- Here we get the startsong and init address from the sid file
jsr music.init
sei
lda #<irq1
sta $0314
lda #>irq1
sta $0315
lda #$1b
sta $d011
lda #$80
sta $d012
lda #$7f
sta $dc0d
sta $dd0d
lda #$81
sta $d01a
lda $dc0d
lda $dd0d
asl $d019
cli
// sei
// lda #<irq1
// sta $0314
// lda #>irq1
// sta $0315
// lda #$1b
// sta $d011
// lda #$80
// sta $d012
// lda #$7f
// sta $dc0d
// sta $dd0d
// lda #$81
// sta $d01a
// lda $dc0d
// lda $dd0d
// asl $d019
// cli
rts

//---------------------------------------------------------
irq1: asl $d019
inc $d020
jsr music.play // <- Here we get the play address from the sid file
dec $d020
jmp $ea81
// irq1: asl $d019
// inc $d020
// jsr music.play // <- Here we get the play address from the sid file
// dec $d020
// jmp $ea81

//---------------------------------------------------------
*=music.location "Music"
Expand Down
107 changes: 107 additions & 0 deletions textscroller.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

initScroller: ldx #40 // init color map
lda #01
sta $dbc0, x
dex
bpl initScroller+4

// sei // set up interrupt
// lda #$7f
// sta $dc0d // turn off the CIA interrupts
// sta $dd0d
// and $d011 // clear high bit of raster line
// sta $d011

// ldy #00 // trigger on first scan line
// sty $d012

// lda #<noscroll // load interrupt address
// ldx #>noscroll
// sta $0314
// stx $0315

// lda #$01 // enable raster interrupts
// sta $d01a
// cli
rts // back to BASIC

noscroll: lda $d016 // default to no scroll on start of screen
and #248 // mask register to maintain higher bits
sta $d016
ldy #242 // trigger scroll on last character row
sty $d012
lda #<scroll // load interrupt address
ldx #>scroll
sta $0314
stx $0315
inc $d019 // acknowledge interrupt
rts

scroll: lda $d016 // grab scroll register
and #248 // mask lower 3 bits
adc offset // apply scroll
sta $d016

dec smooth // smooth scroll
bne continue

dec offset // update scroll
bpl resetsmooth
lda #07 // reset scroll offset
sta offset

shiftrow: ldx #00 // shift characters to the left
lda $07c1, x
sta $07c0, x
inx
cpx #39
bne shiftrow+2

ldx nextchar // insert next character
lda message, x
sta $07e7
inx
lda message, x
cmp #$ff // loop message
bne resetsmooth-3
ldx #00
stx nextchar

resetsmooth: ldx #01 // set smoothing
stx smooth

ldx offset // update colour map
lda colors, x
sta $dbc0
lda colors+8, x
sta $dbc1
lda colors+16, x
sta $dbe6
lda colors+24, x
sta $dbe7

continue: ldy #00 // trigger on first scan line
sty $d012
lda #<noscroll // load interrupt address
ldx #>noscroll
sta $0314
stx $0315
inc $d019 // acknowledge interrupt
rts

offset: .byte 07 // start at 7 for left scroll
smooth: .byte 01
nextchar: .byte 00
//--= WORLDCLASS DEMO - BY ITEMA 1337 HAX0R CREW - FROYA 2020 =--
message: .byte 045, 045, 061, 032, 023, 015, 018, 012
.byte 004, 003, 012, 001, 019, 019, 032, 004
.byte 005, 013, 015, 032, 045, 032, 002, 025
.byte 032, 009, 020, 005, 013, 001, 032, 049
.byte 051, 051, 055, 032, 008, 001, 024, 048
.byte 018, 032, 003, 018, 005, 023, 032, 045
.byte 032, 006, 018, 015, 025, 001, 032, 050
.byte 048, 050, 048, 032, 061, 045, 045, 255
colors: .byte 00, 00, 00, 00, 06, 06, 06, 06
.byte 14, 14, 14, 14, 03, 03, 03, 03
.byte 03, 03, 03, 03, 14, 14, 14, 14
.byte 06, 06, 06, 06, 00, 00, 00, 00