1
0
mirror of https://frontier.innolan.net/github/AmigaExamples.git synced 2026-05-09 22:28:19 +00:00

First attemp at scrolling text

This commit is contained in:
alpine9000
2016-03-31 13:36:24 +11:00
parent 160b78f30a
commit f7d6840c3c
15 changed files with 1020 additions and 0 deletions

31
025.scroll_text/Makefile Normal file
View File

@@ -0,0 +1,31 @@
EXAMPLE_NAME=scroll_text
# userstack used by bootblock
USERSTACK_ADDRESS=7fffc
# if you change this you must also change link.script.x
BASE_ADDRESS=4000
# note: this must be high enough not to conflict with MFMbufE
NUM_COLORS=16
BOOTBLOCK_ASM=alpine_bootblock.s
OBJS=out/init.o out/utils.o out/image.o out/blittext.o out/cpu.o out/blit.o
IMAGES=font8x8.png
IMAGEDATA=$(addprefix out/, $(IMAGES:.png=.bin))
VASM_EXTRA_ARGS=-DNUM_COLORS=$(NUM_COLORS)
#SYMBOL_INFO=-M
LINKER_OPTIONS=-T link.script.x
include ../shared/base.mk
out/%.bin: ../assets/%.png
$(IMAGECON) --input $< $(IMAGECON_ARGS) --output-bitplanes --output-grey-palette-asm --output-palette-asm --output-palette --output out/$* --colors=$(NUM_COLORS) --use-palette palette.pal --full-color-palette-file --output-mask --transparent-color=0,0,0 --output-png
out/simple_image.o: constants.i macros.i
out/blittext.o: constants.i macros.i
out/blit.o: constants.i macros.i
out/main.o: $(IMAGEDATA) constants.i macros.i Makefile link.script.x palette.pal
out/init.o: constants.i Makefile

View File

@@ -0,0 +1,9 @@
scroll text
===========
Work in progress
try it
------
* [Download disk image](bin/scroll_text.adf?raw=true)
* <a href="http://alpine9000.github.io/ScriptedAmigaEmulator/#amiga_examples/scroll_text.adf" target="_blank">Run in SAE</a>

View File

@@ -0,0 +1,352 @@
*** hardware trackloader bootblock
*** original BootLoader.S by Photon ;NOTE: PC-relative code is PREFERRED.
*** see http://coppershade.org/asmskool/SOURCES/Photon-snippets/DDE5-BootLoader.S
*** this version hacked by alpine9000
include "../include/registers.i"
LoaderVars equ $100 ;Useful variables, see CPUinfo:
Loader equ $120 ;start of load script
MyUserStack equ USERSTACK_ADDRESS ;SSP is at a safe place, but set user
;stack.
MFMsync equ $4489 ;AmigaDOS standard sync marker.
MFMlen equ 12980 ;Legacy trackdata read length in bytes
ShortWt:MACRO ;CPU-independent nop;nop replacement
tst.w (a6)
ENDM
*** Boot Block starts here ***
Boot: dc.b 'DOS',0
dc.l 0,880
BootCode: ;gathers some data, turns off OS, copies itself to $100
*--- Fetch system info ---*
move.l 4.w,a6 ;execbase (will soon be destroyed)
move.l 294(a6),d4 ;CPUinfo in lowest byte for your use.
sub.l a4,a4 ;VBR will always be 0 when booting
;from floppy. No GetVBR needed.
*--- Fastmem available? ---*
if 1
move.l #$20004,d1 ;fast+largest
else
move.l #$20002,d1 ;chip+largest
endif
jsr -216(a6) ;AvailMem()
move.l d0,d5
sub.l #2048,d5 ;leave room for stacks to grow
moveq #4,d1
jsr -198(a6) ;AllocMem()
and.l #-8,d0
move.l d0,a5 ;Start Address
*--- OS off ---* ;you're nice'n all, but now you die.
lea $dff002,a6 ;Loader uses this custom base addr
tst.w (a6) ;wait out blitter
.wblit: btst #6,(a6)
bne.s .wblit
move.l #$7fff7fff,d1
move.l d1,$9a-2(a6) ;disable interrupts & req
move.w d1,$9c-2(a6) ;play it again Sam
sub.w #$20,d1 ;don't affect Sprite DMA until Vblank
move.w d1,$96-2(a6) ;disable DMA
lea MyUserStack,a7 ;some safe place compatible with
;platform requirements
*--- Copy rest of code/data to fixed address ---*
lea CopyStart(PC),a0
lea (LoaderVars).w,a1
moveq #(BootE-CopyStart)/8,d2
.copyl: move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
dbf d2,.copyl
JMP (Loader).w ;Info from Exec passed in 4 registers
******************** $100.w ********************
CopyStart:
CPUinfo: dc.l 0 ;$100
FastMemSize: dc.l 0 ;$104
SysVBR: dc.l 0 ;$108
FastMemStart: dc.l 0 ;$10c
MFMcyl: dc.w 0
MFMhead: dc.w 0
MFMdrv: dc.w 0
MFMchk: dc.l 0
dc.w 0 ;padding to $120
dc.w 0 ;
dc.w 0 ;
LoadScript: ;At $120, sysinfo in 4 regs, a6=$dff002
lea CPUinfo(PC),a3 ;Use this for PC-rel in a pinch.
movem.l d4/d5/a4/a5,(a3)
bsr.s WaitEOF
lea NullCop(PC),a0
move.l a0,$80-2(a6) ;blank copper
move.w #$87d0,$96-2(a6) ;enable DMA (sprites enabled when used)
*--- load first part ---*
lea BASE_ADDRESS,a0 ; main entry point
if 1
moveq #2,d0 ;from sector 2
move.w #-1,d1 ;num sectors, - ==Step0
jsr LoadMFMB
move.l 4(a0),d1
add.l #512,d1
lsr.l #6,d1
lsr.l #3,d1
moveq #2,d0 ;from sector 2
jsr LoadMFMB
lea $dff000,a6 ;restore plain custombase addr for demo
move.l (a0),a0
jmp (a0) ; -> main entry point
else
-moveq #2,d0 ;from sector 2
move.w #-((mainEnd-mainStart)/512),d1;num sectors, - ==Step0
jsr LoadMFMB
jmp (a0) ; -> main entry point
endif
*** MFMLoader.S by Photon *** ;requires a6=$dff002
WaitEOF:
btst #0,5-2(a6)
beq.s WaitEOF
.w1: cmp.b #$37,6-2(a6)
bne.s .w1
.w2: cmp.b #$37,6-2(a6) ;wait for last PAL line, $138
beq.s .w2
rts
LoadMFMB: ;loadsectors.a0=dst,d0=startsec.W,d1=nrsecs.W(-=Step0)
MOVEM.L D0-D7/A0-A6,-(SP)
lea $bfd100,a4
bsr MotorOn
tst.w d1 ;if neg length,then Step0 first
bpl.s .NoSt0
neg.w d1
.St0: btst #4,$f01(a4) ;head on cyl 0?
beq.s .Rdy0
bsr.s StepOut
bra.s .St0
.Rdy0: lea MFMcyl(PC),a1
clr.w (a1)
.NoSt0: and.l #$ffff,d0
divu #22,d0 ;startcyl
sub.w MFMcyl(PC),d0 ;delta-step
beq.s .StRdy
bmi.s .StOut
subq.w #1,d0
.StIn: bsr.s StepIn
dbf d0,.StIn
bra.s .StRdy
not.w d0 ;=neg+sub#1
.StOut: bsr.s StepOut
dbf d0,.StIn
.StRdy: swap d0 ;startsec within cyl
cmp.w #11,d0
blt.s .Head0
sub.w #11,d0
bra.s .Head1
.Head0: bset #2,(a4)
lea MFMhead(PC),a1
clr.w (a1)
bsr LoadTrak ;read track+decode
beq.s .End
.Head1: bclr #2,(a4) ;Head 1
lea MFMhead(PC),a1
move.w #1,(a1)
bsr LoadTrak ;read track+decode
beq.s .End
bsr.s StepIn ;1 cyl forward
bra.s .Head0
.End: bsr.s MotorOff
MOVEM.L (SP)+,D0-D7/A0-A6
RTS
StepOut:
bset #1,(a4)
lea MFMcyl(PC),a1
subq.w #1,(a1)
ShortWt
bclr #0,(a4)
ShortWt
bset #0,(a4)
bsr.s StepWt
RTS
StepIn:
bclr #1,(a4)
lea MFMcyl(PC),a1
addq.w #1,(a1)
ShortWt
bclr #0,(a4)
ShortWt
bset #0,(a4)
bsr.s StepWt
RTS
StepWt:
moveq #67,d6 ;wait >3 ms
LeaveLine:
.loop1: move.b 6-2(a6),d7
.loop2: cmp.b 6-2(a6),d7
beq.s .loop2
dbf d6,.loop1
RTS
MotorOn:
move.w MFMdrv(PC),d7
addq.w #3,d7
or.b #$78,(a4)
bset d7,(a4)
ShortWt
bclr #7,(a4) ;turns motor on
ShortWt
bclr d7,(a4)
ShortWt
.DiskR: btst #5,$f01(a4) ;wait until motor running
bne.s .DiskR
RTS
MotorOff:
move.w MFMdrv(PC),d7
addq.w #3,d7
bset d7,(a4)
ShortWt
bset #7,(a4)
ShortWt
bclr d7,(a4)
RTS
LoadTrak: ;loadtrack+decode.a0=dst,d0=secoffs,d1=secsleft
MOVE.W D0,-(SP)
MOVE.W D1,-(SP)
;; lea (MFMbuf).w,a1
lea (MFMbuf),a1
move.w #2,$9c-2(a6) ;Clr Req
move.l a1,$20-2(a6)
move.w #$8210,$96-2(a6) ;DskEna
move.w #MFMsync,$7e-2(a6)
move.w #$9500,$9e-2(a6)
move.w #$4000,$24-2(a6)
move.w #$8000+MFMlen/2,$24-2(a6);DskLen(12980)+DmaEn
move.w #$8000+MFMlen/2,$24-2(a6);start reading MFMdata
.Wrdy:
btst #1,$1f-2(a6) ;wait until data read
beq.s .Wrdy
move.w d0,d2
add.w d1,d2 ;highest sec# (d0=lowest)
cmp.w #11,d2
ble.s .NoOvr
moveq #11,d2
.NoOvr: sub.w d0,d2 ;nrsecs
move.l #$55555555,d3 ;and-const
move.w d2,d1
subq.w #1,d1 ;loopctr
.FindS: cmp.w #MFMsync,(a1)+ ;search for a sync word
bne.s .FindS
cmp.b (a1),d3 ;search for 0-nibble
bne.s .FindS
move.l (a1)+,d4 ;decode fmtbyte/trk#,sec#,eow#
move.l (a1)+,d5
and.w d3,d4
and.w d3,d5
add.w d4,d4
or.w d5,d4
lsr.w #8,d4 ;sec#
sub.w d0,d4 ;do we want this sec?
bmi.s .Skip
cmp.w d2,d4
blt.s .DeCode
.Skip: lea 48+1024(a1),a1 ;nope
bra.s .FindS
.DeCode:lea 40(a1),a1 ;found a sec,skip unnecessary data
move.l a1,d6
lea MFMchk(PC),a1
clr.l (a1)
move.l d6,a1
move.l (a1)+,d6 ;decode data chksum.L
move.l (a1)+,d5
and.l d3,d6
and.l d3,d5
add.l d6,d6
or.l d5,d6 ;chksum
lea 512(a1),a2
add.w d4,d4 ;x512
lsl.w #8,d4
lea (a0,d4.w),a3 ;dest addr for this sec
moveq #127,d7
.DClup: move.l (a1)+,d4
move.l (a2)+,d5
and.l d3,d4
and.l d3,d5
eor.l d4,d6 ;EOR with checksum
eor.l d5,d6 ;EOR with checksum
add.l d4,d4
or.l d5,d4
move.l d4,(a3)+
dbf d7,.DClup ;chksum should now be 0 if correct
lea MFMchk(PC),a1
or.l d6,(a1) ;or with track total chksum
move.l a2,a1
dbf d1,.FindS ;decode next sec
MOVE.W (SP)+,D1
MOVE.W (SP)+,D0
move.l MFMchk(PC),d3 ;track total chksum OK?
bne LoadTrak ;no,retry
moveq #0,d0 ;set to start of track
move.w d2,d3
add.w d3,d3
lsl.w #8,d3
add.w d3,a0
sub.w d2,d1 ;sub #secs loaded
RTS
NullCop:
dc.w $1fc,0
dc.w $100,$0200
dc.w $96,$0020 ;ensure sprite DMA is off until needed
dc.w $ffdf,$fffe
dc.l -2
BootE:
*** Boot Block ends here ***
dc.b "BootLoader by Photon/Scoopex"
;pad bootblock to correct size
cnop 0,1024
;MFMbuf is placed here after bootblock end, $3c0.w or so when copied.
MFMbuf equ LoaderVars+(BootE-CopyStart)
MFMbufE equ MFMbuf+MFMlen ;lowest free address. $372e for a full bootblock.
mainStart:
incbin "out/main.bin"
cnop 0,512
mainEnd:
end

86
025.scroll_text/blit.s Normal file
View File

@@ -0,0 +1,86 @@
include "includes.i"
xdef BlitFillColor
xdef BlitScroll
;; A(mask) B(bob) C(bg) D(dest)
;; - - - -
;; 0 0 0 0
;; 0 0 1 1
;; 0 1 0 0
;; 0 1 1 1
;; 1 0 0 0
;; 1 0 1 0
;; 1 1 0 1
;; 1 1 1 1
BlitFillColor:
;; kills a0,d2,d3,d5,d5
;; a0 - bitplane
;; d0 - color#
;; d1 - height
;; d2 - ypos
;; movem.l d2-d5/a0,-(sp)
mulu.w #BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH,d2
add.l d2,a0
move.b #0,d3 ; bitplane #
.loop:
move.w d1,d4
btst d3,d0 ; is the color's bit set in this plane?
beq .zero
move.w #BLIT_DEST|$FF,d5 ; yes ? all ones
bra .doblit
.zero
move.w #BLIT_DEST|$0,d5 ; no ? all zeros
.doblit
WaitBlitter
move.w #0,BLTCON1(A6)
move.w d5,BLTCON0(A6)
move.w #BITPLANE_WIDTH_BYTES*(SCREEN_BIT_DEPTH-1),BLTDMOD(a6)
move.l a0,BLTDPTH(a6)
lsl.w #6,d4
ori.w #BITPLANE_WIDTH_WORDS,d4
move.w d4,BLTSIZE(a6)
add.b #1,d3
add.w #BITPLANE_WIDTH_BYTES,a0
cmp.b #SCREEN_BIT_DEPTH,d3 ; all planes for a single line done ?
bne .loop ; no ? do the next plane
;; movem.l (sp)+,d2-d5/a0
rts
BlitScroll:
;; kills a0,d1,d2
;; a0 - bitplane
;; d1 - height
;; d2 - ypos
;; movem.l d2-d5/a0,-(sp)
add.l d1,d2 ;point to end of data for ascending mode
mulu.w #BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH,d2
add.l d2,a0
WaitBlitter
move.w #$2,BLTCON1(a6)
move.w #$1000|BLIT_SRCA|BLIT_DEST|$f0,BLTCON0(a6)
move.w #-2,BLTAMOD(a6)
move.w #-2,BLTDMOD(a6)
move.l a0,BLTAPTH(a6)
move.l a0,BLTDPTH(a6)
move.w #$0000,BLTAFWM(a6)
move.w #$ffff,BLTALWM(a6)
mulu.w #SCREEN_BIT_DEPTH,d1
lsl.w #6,d1
ori.w #BITPLANE_WIDTH_WORDS+1,d1
move.w d1,BLTSIZE(a6)
;; movem.l (sp)+,d2-d5/a0
rts

150
025.scroll_text/blittext.s Normal file
View File

@@ -0,0 +1,150 @@
include "includes.i"
xdef DrawText8
BLIT_LF_MINTERM equ $ca ; cookie cut
BLIT_WIDTH_WORDS equ 2 ; blit 2 words to allow shifting
BLIT_WIDTH_BYTES equ 4
FONTMAP_WIDTH_BYTES equ 32
DrawText8:
;; a0 - bitplane
;; a1 - text
;; d0 - xpos
;; d1 - ypos
movem.l d0-d7/a0-a4,-(sp)
WaitBlitter
;; blitter config that is shared for every character
if MASKED_FONT==1
move.w #BLIT_SRCA|BLIT_SRCB|BLIT_SRCC|BLIT_DEST|BLIT_LF_MINTERM,d6 ; BLTCON0 value (masked version)
move.w #FONTMAP_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTAMOD(a6) ; A modulo (only used for masked version)
else
move.w #BLIT_SRCB|BLIT_SRCC|BLIT_DEST|BLIT_LF_MINTERM,d6 ; BLTCON0 value
endif
move.w #FONTMAP_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTBMOD(a6) ; B modulo
move.w #BITPLANE_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTCMOD(a6) ; C modulo
move.w #BITPLANE_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTDMOD(a6) ; D modulo
mulu.w #BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH,d1 ; ypos bytes
move.w #$0000,BLTALWM(a6) ; mask out extra word used for shifting
move.w #$ffff,BLTADAT(a6) ; preload source mask so only BLTA?WM mask is used
move.l a1,a3 ; character pointer
move.l #font,a5 ; font pointer
move.l #fontMask,d7 ; font mask pointer
move.w #FONTMAP_WIDTH_BYTES*SCREEN_BIT_DEPTH*FONT_HEIGHT,d3 ; bytes per font line
.loop:
clr.l d2
move.b (a3)+,d2 ; get next character
cmp.b #0,d2 ; 0 terminates the string
beq .done
move.l a0,a4 ; bitplane pointer
bsr DrawChar8 ; draw it
add.l #FONT_WIDTH,d0 ; increment the x position
bra .loop
.done:
movem.l (sp)+,d0-d7/a0-a4
rts
DrawChar8:
;; kills d2,d4,d5,a1,a2,a4
;; d0 - xpos
;; d1 - ypos bytes
;; d2* - char
;; d3 - bytes per font line
;; d6 - bltcon0 value
;; a4* - bitplane
;; a5 - #font
;; d7 - #fontMask
sub.w #'!',d2 ; index = char - '!'
move.w d2,d5
lsr.w #5,d5 ; char / 32 = fontmap line
andi.w #$1f,d2 ; char index in line (char index - start of line index)
add.l #1,d5 ; while we have a weird font image, '!' starts on second line
move.l a5,a1 ; #font
if 1
mulu.w d3,d5 ; d5 *= #FONTMAP_WIDTH_BYTES*SCREEN_BIT_DEPTH*FONT_HEIGHT
else
move.w d5,d3
lsl.w #7,d3 ; d5 *= FONTMAP_WIDTH_BYTES*SCREEN_BIT_DEPTH
move.w d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
endif
if MASKED_FONT==1
move.l d7,a2 ; #fontMask
add.w d5,a2 ; add y offset in lines to fontMask address
endif
add.w d5,a1 ; add y offset in lines to font address
add.w d2,a1 ; add offset into font
if MASKED_FONT==1
add.l d2,a2 ; add offset into mask
endif
.blitChar8:
;; kills a4,d2,d4,d5
;; d0 - xpos
;; d1 - ypos bytes
;; d2.0 - odd character = 1, even character = 0
;; d3 - bytes per font line
;; d6 - bltcon0 value
;; a4 - display
;; a1 - object
;; a2 - mask
move.l d0,d4 ; xpos
move.l d0,d5 ; xpos
lsr.w #3,d4 ; d4 = xpos bytes
WaitBlitter
btst #0,d2 ; check if odd or even char
beq .evenChar ;
.oddChar
subq #8,d5 ; offset the x position for the odd character
move.w #$00FF,BLTAFWM(a6) ; select the second (odd) character in the word
subq #1,a4 ; move the destination pointer left by one byte
bra .continue
.evenChar:
move.w #$FF00,BLTAFWM(a6) ; select the first character in the word
.continue:
;; this shift will give us the bits to shift (bits 0-3) in bits (12-15) of d5
swap d5 ; d5 << 12
lsr.l #4,d5 ;
move.w d5,BLTCON1(A6) ; set the shift bits 12-15, bits 00-11 cleared
if MASKED_FONT==1
move.l a2,BLTAPTH(a6) ; mask bitplane
endif
move.l a1,BLTBPTH(a6) ; source bitplane
or.w d6,d5 ; d5 = BLTCON0 value
move.w d5,BLTCON0(a6) ; set minterm, dma channel and shift
add.l d4,a4 ; dest += XPOS_BYTES
add.l d1,a4 ; dest += YPOS_BYTES
move.l a4,BLTCPTH(a6) ; background top left corner
move.l a4,BLTDPTH(a6) ; destination top left corner
move.w #(FONT_HEIGHT*SCREEN_BIT_DEPTH)<<6|(BLIT_WIDTH_WORDS),BLTSIZE(a6) ;rectangle size, starts blit
rts
font:
incbin "out/font8x8.bin"
fontMask:
incbin "out/font8x8-mask.bin"

View File

@@ -0,0 +1,47 @@
MASKED_FONT equ 1
if MASKED_FONT==1
BACKGROUND_COLOR equ 4
else
BACKGROUND_COLOR equ 3
endif
FONT_WIDTH equ 8
FONT_HEIGHT equ 8
SCREEN_WIDTH equ 320
SCREEN_HEIGHT equ 256
SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8)
SCREEN_WIDTH_WORDS equ SCREEN_WIDTH_BYTES/2
LEFT_SCREEN_BUFFER equ 16
RIGHT_SCREEN_BUFFER equ 16
LEFT_SCREEN_BUFFER_BYTES equ LEFT_SCREEN_BUFFER/8
RIGHT_SCREEN_BUFFER_BYTES equ RIGHT_SCREEN_BUFFER/8
BITPLANE_WIDTH equ SCREEN_WIDTH+LEFT_SCREEN_BUFFER+RIGHT_SCREEN_BUFFER
BITPLANE_WIDTH_BYTES equ BITPLANE_WIDTH/8
BITPLANE_WIDTH_WORDS equ BITPLANE_WIDTH_BYTES/2
if NUM_COLORS==64
SCREEN_BIT_DEPTH equ 6
endif
if NUM_COLORS==32
SCREEN_BIT_DEPTH equ 5
endif
if NUM_COLORS==16
SCREEN_BIT_DEPTH equ 4
endif
if NUM_COLORS==8
SCREEN_BIT_DEPTH equ 3
endif
if NUM_COLORS==4
SCREEN_BIT_DEPTH equ 2
endif
if NUM_COLORS==2
SCREEN_BIT_DEPTH equ 1
endif
SCREEN_RES equ 8 ; 8=lo resolution, 4=hi resolution
RASTER_X_START equ $81 ; hard coded coordinates from hardware manual
RASTER_Y_START equ $2c
RASTER_X_STOP equ RASTER_X_START+SCREEN_WIDTH
RASTER_Y_STOP equ RASTER_Y_START+256
IMAGESIZE equ BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH*SCREEN_HEIGHT

28
025.scroll_text/cpu.s Normal file
View File

@@ -0,0 +1,28 @@
include "includes.i"
xdef CpuFillColor
CpuFillColor:
;; d0 - color index
;; a0 - bitplane pointer
movem.l d1-d4/a0,-(sp)
move.w #(SCREEN_HEIGHT)-1,d2
.fillLine
move.b #0,d1 ; bitplane #
.fillBitplane:
move.w #(SCREEN_WIDTH_BYTES/4)-1,d3 ; long word moves, so / 4
btst d1,d0 ; is the color's bit set in this plane?
beq .zero
move.l #$FFFFFFFF,d4 ; yes ? all ones
bra .loop
.zero
move.l #0,d4 ; no ? all zeros
.loop:
move.l d4,(a0)+ ; write the data to the plane's line
dbra d3,.loop
add.b #1,d1
cmp.b #SCREEN_BIT_DEPTH,d1 ; all planes for a single line done ?
bne .fillBitplane ; no ? do the next plane
dbra d2,.fillLine ; yes ? do the next line
movem.l (sp)+,d1-d4/a0
rts

36
025.scroll_text/image.s Normal file
View File

@@ -0,0 +1,36 @@
include "includes.i"
xdef SwitchBuffers
SwitchBuffers:
;; offscreen - bitplane address
movem.l d0/a0-a1,-(sp)
move.l offscreen,a0
move.l onscreen,offscreen
move.l a0,onscreen
moveq.l #LEFT_SCREEN_BUFFER_BYTES,d0
move.l a0,a1
lea copperListBplPtr,a0
jsr PokeBitplanePointers
movem.l (sp)+,d0/a0-a1
rts
PokeBitplanePointers:
; d0 = frame offset in bytes
; a0 = BPLP copper list address
; a1 = bitplanes pointer
movem.l d0-a6,-(sp)
add.l d0,a1 ; Offset for odd/even frames
moveq #SCREEN_BIT_DEPTH-1,d0
.bitplaneloop:
move.l a1,d1
move.w d1,2(a0)
swap d1
move.w d1,6(a0)
lea BITPLANE_WIDTH_BYTES(a1),a1
addq #8,a0
dbra d0,.bitplaneloop
movem.l (sp)+,d0-a6
rts

View File

@@ -0,0 +1,9 @@
include "../include/registers.i"
include "../include/vector.i"
include "../include/beambits.i"
include "../include/bplconbits.i"
include "../include/blitter.i"
include "hardware/dmabits.i"
include "hardware/intbits.i"
include "constants.i"
include "macros.i"

32
025.scroll_text/init.s Normal file
View File

@@ -0,0 +1,32 @@
include "includes.i"
xdef Init
;; custom chip base globally in a6
Init:
movem.l d0-a6,-(sp)
;; move #$7ff,DMACON(a6) ; disable all dma
;; move #$7fff,INTENA(a6) ; disable all interrupts
;; lea Level3InterruptHandler,a3
;; move.l a3,LVL3_INT_VECTOR
;; set up playfield
move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6)
move.w #((RASTER_Y_STOP-256)<<8)|(RASTER_X_STOP-256),DIWSTOP(a6)
move.w #(RASTER_X_START/2-SCREEN_RES),DDFSTRT(a6)
move.w #(RASTER_X_START/2-SCREEN_RES)+(8*((SCREEN_WIDTH/16)-1)),DDFSTOP(a6)
move.w #(SCREEN_BIT_DEPTH<<12)|COLOR_ON,BPLCON0(a6)
move.w #BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL1MOD(a6)
move.w #BITPLANE_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL2MOD(a6)
;; install copper list, then enable dma and selected interrupts
lea copperList,a0
move.l a0,COP1LC(a6)
move.w COPJMP1(a6),d0
move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6)
;; move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6)
movem.l (sp)+,d0-a6
rts

View File

@@ -0,0 +1,28 @@
MEMORY
{
disk: org = 0x4000, len = 901120-0x4000
ram: org = 0x00000, len = 0x80000
}
SECTIONS
{
load : {
startCode = .;
*(.text)
*(.data)
*(CODE)
*(DATA)
endCode = .;
} > disk
noload ALIGN(512) : {
startData = .;
*(.noload)
endData = .;
} > disk
bss (NOLOAD) : {
. = endCode;
*(.bss)
} > ram;
}

6
025.scroll_text/macros.i Normal file
View File

@@ -0,0 +1,6 @@
WaitBlitter: macro
tst DMACONR(a6) ;for compatibility
.\@:
btst #6,DMACONR(a6)
bne.s .\@
endm

View File

@@ -0,0 +1,17 @@
000 000 000 255
255 255 255 255
255 000 000 255
000 255 000 255
000 000 255 255
055 255 055 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 255 000 255
255 200 000 255

View File

@@ -0,0 +1,142 @@
include "includes.i"
xdef copperList
xdef onscreen
xdef offscreen
xdef copperListBplPtr
byteMap:
dc.l Entry
dc.l endCode-byteMap
Entry:
lea userstack,a7
lea CUSTOM,a6
move #$7ff,DMACON(a6) ; disable all dma
move #$7fff,INTENA(a6) ; disable all interrupts
jsr InstallPalette
lea Level3InterruptHandler,a3
move.l a3,LVL3_INT_VECTOR
jsr SwitchBuffers
move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6)
move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_MASTER),DMACON(a6)
move.l onscreen,a0
move.l #BACKGROUND_COLOR,d0
move.w #SCREEN_HEIGHT,d1
move.w #0,d2 ; ypos
jsr BlitFillColor
WaitBlitter
jsr Init ; enable the playfield
lea text,a3
MainLoop:
jsr WaitVerticalBlank
jsr InstallPalette
cmp.b #0,(a3)
bne .c1
lea text,a3
.c1:
move.b (a3)+,charbuffer
move.l #BITPLANE_WIDTH-16,d0 ; xpos
move.l #16,d1 ; ypos
move.l onscreen,a0
lea charbuffer,a1
jsr DrawText8
;; bra MainLoop
;; kills a0,d2,d3,d5,d5
;; a0 - bitplane
;; d0 - color#
;; d1 - height
;; d2 - ypos
move.l #8-1,d0
.loop:
move.l onscreen,a0
move.l #FONT_HEIGHT,d1
move.l #16,d2
jsr BlitScroll
jsr WaitVerticalBlank
dbra d0,.loop
bra MainLoop
charbuffer:
dc.b 0
dc.b 0
text:
dc.b "ABCDEFEGHIJLMNOPQRSTUVWXYZabcdefghijlklmnopqrstuvwxyz"
endText:
dc.b 0
align 4
Level3InterruptHandler:
movem.l d0-a6,-(sp)
lea CUSTOM,a6
.checkVerticalBlank:
move.w INTREQR(a6),d0
and.w #INTF_VERTB,d0
beq.s .checkCopper
.verticalBlank:
move.w #INTF_VERTB,INTREQ(a6) ; clear interrupt bit
.checkCopper:
move.w INTREQR(a6),d0
and.w #INTF_COPER,d0
beq.s .interruptComplete
.copperInterrupt:
move.w #INTF_COPER,INTREQ(a6) ; clear interrupt bit
.interruptComplete:
movem.l (sp)+,d0-a6
rte
copperList:
copperListBplPtr:
dc.w BPL1PTL,0
dc.w BPL1PTH,0
dc.w BPL2PTL,0
dc.w BPL2PTH,0
dc.w BPL3PTL,0
dc.w BPL3PTH,0
dc.w BPL4PTL,0
dc.w BPL4PTH,0
dc.w BPL5PTL,0
dc.w BPL5PTH,0
dc.w BPL6PTL,0
dc.w BPL6PTH,0
dc.l $fffffffe
InstallPalette:
include "out/font8x8-palette.s"
rts
GreyPalette:
include "out/font8x8-grey.s"
rts
onscreen:
dc.l bitplanes1
offscreen:
dc.l bitplanes2
section .bss
bitplanes1:
ds.b IMAGESIZE+(512)
bitplanes2:
ds.b IMAGESIZE+(512*2)
startUserstack:
ds.b $1000 ; size of stack
userstack:

47
025.scroll_text/utils.s Normal file
View File

@@ -0,0 +1,47 @@
include "includes.i"
xdef WaitVerticalBlank
xdef WaitRaster
xdef Depack
WaitVerticalBlank:
movem.l d0,-(sp)
.loop: move.l $dff004,d0
and.l #$1ff00,d0
cmp.l #303<<8,d0 ; wait for the scan line
bne.b .loop
.loop2 move.l $dff004,d0
and.l #$1ff00,d0
cmp.l #303<<8,d0 ; wait for the scan line to pass (A4000 is fast!)
beq.b .loop2
movem.l (sp)+,d0
rts
WaitRaster: ;wait for rasterline d0.w. Modifies d0-d2/a0.
movem.l d0-a6,-(sp)
move.l #$1ff00,d2
lsl.l #8,d0
and.l d2,d0
lea $dff004,a0
.wr: move.l (a0),d1
and.l d2,d1
cmp.l d1,d0
bne.s .wr
movem.l (sp)+,d0-a6
rts
Depack:
;a0 = input buffer to be decompressed. Must be 16-bit aligned!
;a1 = output buffer. Points to the end of the data at exit
movem.l d0-a6,-(sp)
bsr doynaxdepack ; decompress data
movem.l (sp)+,d0-a6
rts
;; this is one FAST decompression routine!
include "../tools/external/doynamite68k/depacker_doynax.asm"