View Single Post
Old 22 September 2019, 21:45   #9
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
A real example: "It's a sin" by Planet Jazz.
It's a 1KB bootblock intro with source code available, full PC relative.

I chose this because I took the opportunity to fix some small bugs that prevents it to exit to CLI regularly.

Greeting to the original coder

Code:
;Planet Jazz - It's a sin bootblock for Datastorm 2017
;Partycoded by Olle using Blueberrys bootblock examplecode.
;It's not only a sin, it is also a complete mess. :)

; little fix by ross 22/09-2019

; Bootblock example code by Blueberry / Loonies, 23/9-2012
; Public Domain

; System constants
_LVOFindResident = -96
_LVOLoadView = -222
_LVOWaitTOF = -270
gb_ActiView = 34
gb_copinit = 38
IVBLIT = 156
RT_INIT = 22
SU_tf_CharData = $22
SU_OpenFont = -72

_AUD0LCH = $A0
_AUD0LEN = $A4
_AUD0PER = $A6
_AUD0VOL = $A8
_AUD2LCH = $C0
_AUD2LEN = $C4
_AUD2PER = $C6
_AUD2VOL = $C8

Mask = 2048-1


	section	BB,code

; The bootblock starts here.
; It cannot generally be assumed to be placed in a specific
; kind of memory, or at any specific address, so all code
; must be completely PC relative, and all chip data must
; be explicitly copied to chip memory.

BB:
	DC.B	'DOS',0
	DC.L	0
	DC.L	$370

START:
	; Bootblock code goes here.
	movem.l	d0-a6,-(sp)

	; Global pointer to chip space in A4
	; Chip space at the end of (512k) chip memory
	lea	$80000-4096-(Space_End-Space),a4

	; Open topaz
;	movea.l	$4.w,a6
	movea.l	IVBLIT(a6),a6	; graphics.library
	lea	TextAttr(pc),a0
	lea	TopazName(pc),a1
	move.l	a1,(a0)
	jsr	SU_OpenFont(a6)
	movea.l	d0,a0
	move.l	SU_tf_CharData(a0),TopazCharData-Space(a4)

	lea	TextScr-Space(a4),a0
	lea	Bpl2-Space(a4),a1
	move.w	#$00e4,d1
	bsr.w	SetBpl
	addq.w	#2,d1
	adda.l	#(80*1)+2,a0
	bsr.w	SetBpl

	lea	Kottig_Text(pc),a0
	lea	TextMsg-Space(a4),a1
	moveq	#(Kottig_TextE-Kottig_Text)/4-1,d7
.tloop	move.l	(a0)+,(a1)+
	dbf	d7,.tloop

	; Copy copperlist to chip
	lea	CopperData(pc),a0
	lea	Copper-Space(a4),a1
	moveq	#(CopperData_End-CopperData)/4-1,d7
.cloop	move.l	(a0)+,(a1)+
	dbf	d7,.cloop

	move.l	#$00280078,Yptr1-Space(a4)
	
	lea	TextMsg-Space(a4),a0
	move.l	a0,Textptr-Space(a4)

	lea	$DFF000,A5
	move.w	2(a5),-(sp)
	ori.w	#$8000,(sp)

	;init sound
	lea	Waveform-Space(a4),a1
	move.w	#$7f80,(a1)

	move.l	a1,_AUD0LCH(a5)
	move.w	#1,_AUD0LEN(a5)
	move.l	a1,_AUD2LCH(a5)
	move.w	#1,_AUD2LEN(a5)

;	bsr.w	gen_sin
	lea	Bpl_Sinus-Space(a4),a0
	lea	1024(a0),a1
	moveq	#0,d4
	move	#256-1,d3
.l1	move.l	d4,d0
	swap	d0
	add.l	#823550,d4	;Pi<<18
	move	d0,d2
	move	d0,d1
	mulu	d1,d1
	lsl.l	#4,d1
	swap	d1
	mulu	d1,d0
	divu	#3<<11,d0
	sub	d0,d2
	mulu	d1,d0
	divu	#10<<11,d0
	add	d0,d2
	mulu	d1,d0
	divu	#21<<11,d0
	sub	d0,d2
	asr	#4,d2

	move	d2,(a0)+
	move	d2,2046(a0)
	move	d2,-(a1)
	neg	d2
	move	d2,1022(a0)
	move	d2,1024(a1)
	dbf	d3,.l1


;	bsr.w	render_triangle
	moveq	#0,d1
	moveq	#0,d7
	lea	TScreen-Space(a4),a0
	move.l	#640/2,d0
.floop	subq.l	#1,d0
	add.l	#80,d1
	move.w	d7,d2
	lsl.w	#1,d2

	move.l	d0,d3
.fscanl
;	bfset	(a0,d1.w){d3:01}		; 68020+ method
; 68000-method ;(
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	move.l	d3,d4				; x
	move.l	d1,d5				; y
	ror.l	#3,d4
	add.l	d4,d5				; + x position in bit(!)[*]
	rol.l	#3,d4				; /8 - now we have byte offset
	not	d4				; correct offset for bitset
	bset	d4,(a0,d5.w)
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	addq.l	#1,d3
	dbra	d2,.fscanl

	addq.w	#1,d7
	cmp.w	#320,d7
	bne.b	.floop

;	bsr.w	fill_copper
	lea	Bplist-Space(a4),a0
	move.l	#$1ee1fffe,d0
	move.l	#300-1,d1
.fill	move.l	d0,(a0)+
	move.l	#$00e00000,(a0)+
	move.l	#$00e20000,(a0)+
	add.l	#$01000000,d0
	dbra	d1,.fill

	; Set copperlist
	lea	Copper-Space(a4),a1
	move.l	a1,$80(a5)

	; Disable interrupts and set some DMAs
	move.w	#$4000,$9a(a5)
	move.w	#$87C5,$96(a5)
;	move.w	#%1000000000000101,_DMACON(a5)

	; Switch off sprite DMA
;	bsr.w	WaitVbl
	move.w	#$0020,$96(a5)

	; Main per-frame loop
MainLoop
;	bsr.w	do_sine
	move.w	Yptr1-Space(a4),d2
	move.w	Yptr2-Space(a4),d3
	lea	Bpl_Sinus-Space(a4),a0
	lea	TScreen-Space(a4),a1		; Triangle screen
	lea	Bplist-Space(a4),a2
	move.l	#300-1,d7
.loop	move.w	(a0,d2),d4
	add.w	(a0,d3),d4
	asr.w	#2,d4
	add.w	#100,d4
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	mulu	#80,d4
	add.l	a1,d4
	move.w	d4,10(a2)
	swap	d4
	move.w	d4,6(a2)
	add.l	#12,a2
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	add.w	#8*4,d2
	add.w	#4*4,d3
	and.w	#Mask,d2
	and.w	#Mask,d3
	dbra	d7,.loop
	move.w	Yptr1-Space(a4),d2
	move.w	Yptr2-Space(a4),d3	
	add.w	#2*4,d2
	add.w	#4*4,d3
	and.w	#Mask,d2
	and.w	#Mask,d3
	move.w	d2,Yptr1-Space(a4)
	move.w	d3,Yptr2-Space(a4)

	bsr.w	write_text
	
;-------------- audio --------------
;do_drum
	cmp.w	#32,Ticks-Space(a4)
	bne.b	.ntrig
	move.w	#124,Per-Space(a4)
	move.w	#64,Vol-Space(a4)
	clr.w	Ticks-Space(a4)
.ntrig
	addq.w	#1,Ticks-Space(a4)

	move.w	Per-Space(a4),_AUD0PER(a5)
	move.w	Vol-Space(a4),_AUD0VOL(a5)

	add.w	#12<<8,Per-Space(a4)
	subq.w	#8,Vol-Space(a4)

	move.w	Per-Space(a4),_AUD2PER(a5)
	move.w	Vol-Space(a4),_AUD2VOL(a5)
;----------------------------------
	bsr.b	WaitVbl

	; Loop until LMB
	btst	#6,$bfe001
	bne.w	MainLoop

Exit:
	; Recover DMA settings
	move.w	#$7fff,$96(a5)
	move.w	(sp)+,$96(a5)

	; Restore copper
;	move.l	IVBLIT(a6),a6
	move.l	gb_copinit(a6),$80(a5)

	; Restore registers
	movem.l	(sp)+,d0-a6

	; Return init function of dos.library resident in A0
	lea	DosName(pc),a1
	jsr	_LVOFindResident(a6)
	movea.l	d0,a0
	movea.l	RT_INIT(a0),a0
	moveq	#0,d0
	rts

WaitVbl
	tst.b	5(a5)
	beq.b	WaitVbl
.wvb
	tst.b	5(a5)
	bne.b	.wvb
	rts

SetBpl
	move.l	a0,d0
	move.w	d1,(a1)+	;$00ex
	swap	d0
	move.w	d0,(a1)+	;h
	swap	d0
	addq.w	#2,d1
	move.w	d1,(a1)+	;$00ex
	move.w	d0,(a1)+	;l
	rts

;-----------------------------------

; Textwriter using Topaz font.
write_text
	lea	TextScr-Space(a4),a1
	adda.l	#80*8+20-2+((80*10)*5),a1

	movea.l	Textptr-Space(a4),a0
.getch	moveq	#0,d0
	move.b	(a0)+,d0
	beq.b	.fin			; if 0 then finished
	move.l	a0,Textptr-Space(a4)

	tst.b	d0			; repeat space $7f+no of spaces
	bpl.b	.norepspace
	sub.w	#$7f,d0
	add.w	d0,TextCursorx-Space(a4)
	bra.b	.getch
.norepspace

	cmp.b	#10,d0			; newline
	bne.b	.cont
	add.w	#80*10,TextCursory-Space(a4)
	clr.w	TextCursorx-Space(a4)
	bra.b	.getch
.cont	sub.b	#32,d0
	move.l	TopazCharData-Space(a4),a0
	add.w	d0,a0

	add.w	TextCursorx-Space(a4),a1
	add.w	TextCursory-Space(a4),a1
	moveq	#8-1,d0
.cpy	move.b	(a0),(a1)
	add.w	#192,a0
	add.w	#80,a1
	dbra	d0,.cpy
	addq.w	#1,TextCursorx-Space(a4)
.fin	rts

Kottig_Text
	dc.b	$7f+14,'At DataStorm 2017',10,10,10
	dc.b	$7f+13,'Planet.Jazz cracked',10
	dc.b	$7f+13,'Several braincells',10
	dc.b	10,10,10
	dc.b	$7f+7,'Greetings to everyone at the party',10,10
	dc.b	$7f+4,'and heck, even to the sofa-sceners :P',10
	dc.b	10,10,10,10,10,10,10
	dc.b	'partycode, same procedure as every year james.',0
	even
Kottig_TextE

CopperData
	dc.w	$0100,$b000,$008e,$2c81,$0090,$2cc1
	dc.w	$0092,$003c,$0094,$00d4
	dc.w	$0108,$0000,$010a,$0000
	dc.w	$0102,$0407
	dc.w	$0180,$05c5,$0182,$04a4
	dc.w	$0184,$0151,$0186,$0141
	dc.w	$0188,$0fef,$018a,$0fff
	dc.w	$018c,$0fef,$018e,$0fff
CopperData_End

DosName	dc.b	'dos.library',0

TextAttr
	dc.l	0
	dc.w	8
	dc.b	0,0
TopazName
	dc.b	'topaz.font',0
	even


;		section	space,bss_c
Space
Ticks		ds.w	1
Per		ds.w	1
Vol		ds.w	1
Yptr1		ds.w	1
Yptr2		ds.w	1
Sq		ds.w	1
TextCursorx	ds.w	1
TextCursory	ds.w	1
Textptr		ds.l	1
TopazCharData	ds.l	1
TextMsg		ds.b	Kottig_TextE-Kottig_Text
Bpl_Sinus	ds.w	4096
Waveform	ds.l	1
Copper		ds.b	CopperData_End-CopperData
Bpl2		ds.w	4	;dc.w	$00e4,$0000,$00e6,$0000
Bpl3		ds.w	4	;dc.w	$00e8,$0000,$00ea,$0000
Bplist		ds.w	300*6	; Triangle bitplane ptrs
		ds.l	1	; Terminator
TextScr		ds.b	80*256
TScreen		ds.b	80*640
Space_End
EDIT
Just noticed two small inaccuracies in the copper list.
But the purpose was a bb intro example so it doesn't matter
Attached Files
File Type: zip pjz-its_a_sin[f ross].zip (5.0 KB, 186 views)

Last edited by ross; 22 September 2019 at 22:54.
ross is offline  
 
Page generated in 0.04412 seconds with 12 queries