Difference between revisions of "Homebrew:CCtro"

From veswiki
Jump to: navigation, search
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
[http://channelf.se/veswiki/index.php?title=File:Cctro.bin Download bin (2048 Bytes)]
 
[http://channelf.se/veswiki/index.php?title=File:Cctro.bin Download bin (2048 Bytes)]
 
<br><br>
 
<br><br>
This is the disassembly of CCtro by frog, partially annotated. This code is copyright © 1976 Fairchild Semiconductor.
+
Original assembly code of CCtro by Frog.
  
 
<pre>
 
<pre>
    org $0800
+
; CCtro - 256 bytes intro for Fairchild Channel F by Frog
 +
; frog@enlight.ru
 +
; https://enlight.ru/roi
 +
;
 +
; p.s. thanks to http://channelf.se/veswiki people
  
CartridgeStart:
+
processor f8
                LR  $5,A                ; 0800 55
 
                NOP                      ; 0801 2b
 
  
CartridgeEntry:
+
clrscrn = $00d0 ; uses r31
                LI  $c6                ; 0802 20 c6    ; Clear screen through BIOS, grey
+
delay = $008f
                LR  $3,A                ; 0804 53
+
drawchar = $0679 ; prints char r0 (code+color) at col r1, row r2
                PI  $00d0              ; 0805 28 00 d0
 
  
                LI  $02                ; 0808 20 02
+
xc0 = 29 ; chars x0
                LR  $5,A                ; 080a 55
+
yc0 = 27 ; chars y0
                LI  $0b                ; 080b 20 0b
 
                LR  $4,A                ; 080d 54
 
                LI  $40                ; 080e 20 40
 
                LR  $1,A                ; 0810 51
 
A0811:          LR  A,$4                ; 0811 44
 
                AI  $17                ; 0812 24 17
 
                LR  $3,A                ; 0814 53
 
                LI  $32                ; 0815 20 32
 
                LR  $7,A                ; 0817 57
 
                LI  $01                ; 0818 20 01
 
                XS  $8                  ; 081a e8
 
                LR  $8,A                ; 081b 58
 
                LI  $67                ; 081c 20 67
 
                AS  $8                  ; 081e c8
 
                LR  $2,A                ; 081f 52
 
A0820:          LI  $80                ; 0820 20 80
 
                LR  $1,A                ; 0822 51
 
  
                PI  A08eb              ; 0823 28 08 eb
+
org $800
                DS  $2                  ; 0826 32
 
                DS  $2                  ; 0827 32
 
                DS  $7                  ; 0828 37
 
                BF  $4,A0820            ; 0829 94 f6
 
                DS  $4                  ; 082b 34
 
                BF  $4,A0811            ; 082c 94 e4
 
                LI  $31                ; 082e 20 31
 
                LR  $1,A                ; 0830 51
 
                LI  $1b                ; 0831 20 1b
 
                LR  $2,A                ; 0833 52
 
                LI  $c1                ; 0834 20 c1
 
                LR  $0,A                ; 0836 50
 
                PI  $0679              ; 0837 28 06 79
 
                LI  $29                ; 083a 20 29
 
                LR  $1,A                ; 083c 51
 
                LI  $ca                ; 083d 20 ca
 
                LR  $0,A                ; 083f 50
 
                PI  $0679              ; 0840 28 06 79
 
                LI  $2e                ; 0843 20 2e
 
                LR  $1,A                ; 0845 51
 
                LI  $ca                ; 0846 20 ca
 
                LR  $0,A                ; 0848 50
 
                PI  $0679              ; 0849 28 06 79
 
                LI  $35                ; 084c 20 35
 
                LR  $1,A                ; 084e 51
 
                LI  $82                ; 084f 20 82
 
                LR  $0,A                ; 0851 50
 
                PI  $0679              ; 0852 28 06 79
 
                LI  $3f                ; 0855 20 3f
 
                LR  $1,A                ; 0857 51
 
                LI  $81                ; 0858 20 81
 
                LR  $0,A                ; 085a 50
 
                PI  $0679              ; 085b 28 06 79
 
                LI  $3b                ; 085e 20 3b
 
                LR  $1,A                ; 0860 51
 
                LI  $80                ; 0861 20 80
 
                LR  $0,A                ; 0863 50
 
                PI  $0679              ; 0864 28 06 79
 
                LI  $43                ; 0867 20 43
 
                LR  $1,A                ; 0869 51
 
                LI  $89                ; 086a 20 89
 
                LR  $0,A                ; 086c 50
 
                PI  $0679              ; 086d 28 06 79
 
A0870:          LI  $0d                ; 0870 20 0d
 
                LR  $0,A                ; 0872 50
 
A0873:          LI  $17                ; 0873 20 17
 
                AS  $0                  ; 0875 c0
 
                LR  $3,A                ; 0876 53
 
                LIS  $0                  ; 0877 70
 
                LR  $1,A                ; 0878 51
 
                LI  $7e                ; 0879 20 7e
 
                LR  $2,A                ; 087b 52
 
                PI  A08eb              ; 087c 28 08 eb
 
                LI  $ff                ; 087f 20 ff
 
                LR  $1,A                ; 0881 51
 
                DS  $2                  ; 0882 32
 
                PI  A08eb              ; 0883 28 08 eb
 
                LR  A,$3                ; 0886 43
 
                LR  $4,A                ; 0887 54
 
                DS  $3                  ; 0888 33
 
                LI  $ff                ; 0889 20 ff
 
                LR  $1,A                ; 088b 51
 
                LI  $7e                ; 088c 20 7e
 
                LR  $2,A                ; 088e 52
 
                PI  A08eb              ; 088f 28 08 eb
 
                DS  $2                  ; 0892 32
 
                PI  A08eb              ; 0893 28 08 eb
 
                LI  $7e                ; 0896 20 7e
 
                LR  $2,A                ; 0898 52
 
                LI  $17                ; 0899 20 17
 
                LR  $3,A                ; 089b 53
 
                LIS  $0                  ; 089c 70
 
                LR  $1,A                ; 089d 51
 
                LR  A,$8                ; 089e 48
 
                LR  $1,A                ; 089f 51
 
                PI  A08eb              ; 08a0 28 08 eb
 
                DS  $2                  ; 08a3 32
 
                LIS  $0                  ; 08a4 70
 
                LR  $1,A                ; 08a5 51
 
                PI  A08eb              ; 08a6 28 08 eb
 
                LR  A,$3                ; 08a9 43
 
                AI  $0c                ; 08aa 24 0c
 
                LR  $3,A                ; 08ac 53
 
                LR  A,$2                ; 08ad 42
 
                INC                      ; 08ae 1f
 
                LR  $2,A                ; 08af 52
 
                LR  A,$8                ; 08b0 48
 
                LR  $1,A                ; 08b1 51
 
                PI  A08eb              ; 08b2 28 08 eb
 
                DS  $2                  ; 08b5 32
 
                LIS  $0                  ; 08b6 70
 
                LR  $1,A                ; 08b7 51
 
                PI  A08eb              ; 08b8 28 08 eb
 
                LR  A,$8                ; 08bb 48
 
                XI  $ff                ; 08bc 23 ff
 
                LR  $8,A                ; 08be 58
 
                LR  A,$4                ; 08bf 44
 
                LR  $3,A                ; 08c0 53
 
                LI  $28                ; 08c1 20 28
 
                LR  $1,A                ; 08c3 51
 
A08c4:          LI  $ff                ; 08c4 20 ff
 
                LR  $2,A                ; 08c6 52
 
A08c7:          DS  $2                  ; 08c7 32
 
                BF  $4,A08c7            ; 08c8 94 fe
 
                DS  $1                  ; 08ca 31
 
                BF  $4,A08c4            ; 08cb 94 f8
 
                DS  $0                  ; 08cd 30
 
                BF  $4,A0873            ; 08ce 94 a4
 
                DS  $3                  ; 08d0 33
 
                LIS  $0                  ; 08d1 70
 
                LR  $1,A                ; 08d2 51
 
                LI  $7e                ; 08d3 20 7e
 
                LR  $2,A                ; 08d5 52
 
                PI  A08eb              ; 08d6 28 08 eb
 
                LI  $ff                ; 08d9 20 ff
 
                LR  $1,A                ; 08db 51
 
                DS  $2                  ; 08dc 32
 
                PI  A08eb              ; 08dd 28 08 eb
 
                LI  $c0                ; 08e0 20 c0
 
                OUTS 5                  ; 08e2 b5
 
                LIS  $0                  ; 08e3 70
 
                OUTS 5                  ; 08e4 b5
 
                JMP  A0870              ; 08e5 29 08 70
 
A08e8:          JMP  A08e8              ; 08e8 29 08 e8
 
A08eb:          LR  A,$1                ; 08eb 41
 
                OUTS 1                  ; 08ec b1
 
                LR  A,$2                ; 08ed 42
 
                COM                      ; 08ee 18
 
                OUTS 4                  ; 08ef b4
 
                LR  A,$3                ; 08f0 43
 
                COM                      ; 08f1 18
 
                OUTS 5                  ; 08f2 b5
 
                LI  $60                ; 08f3 20 60
 
                OUTS 0                  ; 08f5 b0
 
                LI  $50                ; 08f6 20 50
 
                OUTS 0                  ; 08f8 b0
 
                LIS  $6                  ; 08f9 76
 
A08fa:          AI  $ff                ; 08fa 24 ff
 
                BF  $4,A08fa            ; 08fc 94 fd
 
                POP                      ; 08fe 1c
 
  
 +
cartridgeStart:
 +
.byte $55, $2B ; cartridge header
 +
 +
cartridgeEntry:
 +
 +
li $c6 ; $21 - b/w palette, fill with black. $c6 - color palette, fill with gray
 +
lr 3, A
 +
pi clrscrn ; clrscrn BIOS call
 +
 +
 +
; draw checkerboard -----------------------------------------
 +
; clr 8 ; 0-> r8. (r8 used to flip bit 0/1) [commented by e5frog, not needed and not working code]
 +
li 2 ; shift (0|1)
 +
lr 5, a
 +
 +
li 11 ; (r4) number of iterations (ysize)
 +
lr 4,a ; a->r4
 +
 +
li $40 ; color
 +
lr 1, a
 +
 +
nextln:
 +
 +
lr a,4 ; load y0
 +
ai 23 ; a+const->a  (y0)
 +
lr 3, a
 +
 +
li 50 ; related to xsize
 +
lr 7,a ; (r7) number of iterations (x)
 +
 +
; xor r8 with 1 (flip 1 <-> 0)
 +
li 1
 +
xs 8 ; a xor r8 -> a
 +
lr 8,a
 +
 +
; r8 + 103 -> r2
 +
li 103 ; related to x0 WAS:42
 +
as 8 ; x = x+y (shift by 1 pixel)
 +
lr 2,a ; (r2) coord (x)
 +
 +
 +
; draw dotted line
 +
nextpx:
 +
 +
li $80 ; color ($00, $40, $80)
 +
lr 1,a
 +
 +
pi plot ; r1 - color, r2 - x, r3 - y  (a,r6 also lost)
 +
 +
ds 2 ; r2-- (coord)
 +
ds 2 ; r2-- (coord)
 +
 +
ds 7 ; r7-- (number of iterations)
 +
bnz nextpx ; until r7 = 0
 +
 +
ds 4 ; r4--
 +
bnz nextln ; until r2 = 0
 +
 +
 +
 +
; draw chars "CC2019" (GG1 used to make inversed CC because lack of "C" in BIOS)
 +
; "1"
 +
li 20 + xc0 ; x
 +
lr 1,a
 +
li yc0 ; y
 +
lr 2,a
 +
li $c1
 +
lr 0,a ; combined color + char index -> r0
 +
pi drawchar           
 +
 +
; "G"
 +
li 12 + xc0 ; x
 +
lr 1,a
 +
li $ca
 +
lr 0,a ; combined color + char index -> r0
 +
pi drawchar           
 +
 +
; "G"
 +
li 17 + xc0 ; x
 +
lr 1,a
 +
li $ca
 +
lr 0,a ; combined color + char index -> r0
 +
pi drawchar           
 +
 +
; "2"
 +
li 24 + xc0 ; x
 +
lr 1,a
 +
li $82
 +
lr 0,a ; combined color + char index -> r0
 +
pi drawchar           
 +
; "1"
 +
li 34 + xc0 ; x
 +
lr 1,a
 +
li $81
 +
lr 0,a ; combined color + char index -> r0
 +
pi drawchar           
 +
; "0"
 +
li 30 + xc0 ; x
 +
lr 1,a
 +
li $80
 +
lr 0,a ; combined color + char index -> r0
 +
pi drawchar           
 +
; "9"
 +
li 38 + xc0 ; x
 +
lr 1,a
 +
li $89
 +
lr 0,a ; combined color + char index -> r0
 +
pi drawchar           
 +
 +
 +
AGAIN:
 +
 +
li 13 ; (r0) number of iterations
 +
lr 0,a ; a->r0
 +
 +
nextline:
 +
 +
li 23 ; y0
 +
as 0 ; r0+a->a
 +
lr 3,a
 +
 +
; set palette for line (y: r3)
 +
;
 +
; 00->125, 00->126: rgb, lightgreen back
 +
; 00->125, ff->126: rgb, lightblue back
 +
; ff->125, 00->126: rgb, transparent (gray) back
 +
; ff->125, ff->126: www, black back
 +
 +
 +
; restore color of lower line  (e.g. 5 with gray back)
 +
 +
clr ; color (0 -> a)
 +
lr 1,a
 +
 +
li 126 ; x
 +
lr 2,a
 +
 +
pi plot
 +
 +
li $ff ; color
 +
lr 1,a
 +
 +
ds 2
 +
pi plot
 +
 +
lr a,3 ; save r3
 +
lr 4,a
 +
 +
ds 3
 +
 +
; change color of upper line  (e.g. 6 with black back)
 +
 +
li $ff ; color
 +
lr 1, a
 +
 +
li 126 ; x
 +
lr 2, a
 +
 +
pi plot
 +
ds 2
 +
pi plot
 +
 +
;------
 +
 +
; blinking lines
 +
 +
 +
li 126 ; x
 +
lr 2, a
 +
 +
li 23 ; y
 +
lr 3, a
 +
 +
clr ; color
 +
lr 1, a
 +
 +
 +
lr a,8 ; color
 +
lr 1, a
 +
pi plot
 +
 +
ds 2
 +
 +
clr ; color
 +
lr 1, a
 +
pi plot
 +
 +
lr a,3
 +
ai 12 ; a+=12
 +
lr 3,a
 +
 +
lr a,2
 +
inc
 +
lr 2,a
 +
 +
lr a,8 ; color
 +
lr 1,a
 +
pi plot
 +
 +
ds 2
 +
 +
clr ; color
 +
lr 1,a
 +
pi plot
 +
 +
lr a,8
 +
xi $ff ; change 00 with FF to blink
 +
lr 8,a
 +
 +
 +
 +
lr a,4 ; restore r3
 +
lr 3,a
 +
 +
 +
; setpal end
 +
 +
 +
 +
; delay moving line through the checkerboard
 +
 +
li 40
 +
lr 1,a
 +
delay2:         
 +
li $ff
 +
lr 2,a               
 +
delay1:   
 +
ds 2                 
 +
bnz delay1         
 +
ds 1
 +
bnz delay2           
 +
 +
 +
 +
ds 0 ; r0--
 +
bnz nextline ; until r0 = 0
 +
 +
; restore top line
 +
 +
 +
; restore color of lower line  (e.g. 5 with gray back)
 +
ds 3
 +
 +
clr ; color (0->a)
 +
lr 1, a
 +
 +
li 126 ; x
 +
lr 2, a
 +
 +
pi plot
 +
 +
li $ff ; color
 +
lr 1, a
 +
 +
ds 2
 +
pi plot
 +
 +
li %11000000  ; 1kHz beep $40 (rather click)
 +
outs 5
 +
clr
 +
outs 5
 +
 +
jmp AGAIN
 +
 +
loop: jmp loop
 +
 +
 +
; plot point
 +
; r1 = color  $00 = green, $40 = %01000000 = red, $80 = %10000000 = blue, $C0 = %11000000 = background
 +
; r2 = x (to screen) (4-105) (0-101)
 +
; r3 = y (to screen) (4-61) (0-57)
 +
 +
plot:
 +
; set the color using r1
 +
lr A, 1
 +
outs 1
 +
 +
; set the column using r2
 +
lr A, 2
 +
com
 +
outs 4
 +
 +
; set the row using r3
 +
lr A, 3
 +
com
 +
outs 5
 +
 +
; transfer data to the screen memory
 +
li $60
 +
outs 0
 +
li $50
 +
outs 0
 +
 +
; delay until it's fully updated
 +
lis 6
 +
.plotDelay:
 +
ai $ff
 +
bnz .plotDelay
 +
 +
pop ; return from the subroutine
 +
 +
 +
org $fff        ; added only to set a useable rom-size in MESS
 +
.byte  $ff
 
</pre>
 
</pre>

Revision as of 20:56, 31 August 2019

CCtro by Frog //ROi (Peter Sobolev), released at Chaos Constructions'2019.

https://www.pouet.net/prod.php?which=82729
Download bin (2048 Bytes)

Original assembly code of CCtro by Frog.

; CCtro - 256 bytes intro for Fairchild Channel F by Frog
; frog@enlight.ru
; https://enlight.ru/roi
; 
; p.s. thanks to http://channelf.se/veswiki people

	processor f8

clrscrn	= $00d0		; uses r31
delay	= $008f
drawchar = $0679	; prints char r0 (code+color) at col r1, row r2

xc0 = 29	; chars x0
yc0 = 27	; chars y0 

	org	$800

cartridgeStart:
	.byte	$55, $2B		; cartridge header

cartridgeEntry:

	li	$c6			; $21 - b/w palette, fill with black. $c6 - color palette, fill with gray
	lr	3, A
	pi	clrscrn			; clrscrn BIOS call


; draw checkerboard -----------------------------------------
;	clr	8			; 0-> r8. (r8 used to flip bit 0/1) [commented by e5frog, not needed and not working code]
	li	2			; shift (0|1)
	lr	5, a

	li	11			; (r4) number of iterations (ysize)
	lr	4,a			; a->r4

	li	$40			; color
	lr	1, a

nextln:

	lr	a,4			; load y0
	ai	23			; a+const->a  (y0)
	lr	3, a

	li	50			; related to xsize
	lr	7,a			; (r7) number of iterations (x)

; xor r8 with 1 (flip 1 <-> 0)
	li	1
	xs	8				; a xor r8 -> a
	lr	8,a

; r8 + 103 -> r2
	li	103			; related to x0 WAS:42
	as	8			; x = x+y (shift by 1 pixel) 
	lr	2,a			; (r2) coord (x)


; draw dotted line
nextpx:

	li	$80			; color ($00, $40, $80)
	lr	1,a

	pi plot			; r1 - color, r2 - x, r3 - y  (a,r6 also lost)

	ds	2			; r2-- (coord)
	ds	2			; r2-- (coord)

	ds	7			; r7-- (number of iterations)
	bnz nextpx		; until r7 = 0

	ds	4			; r4--
	bnz nextln		; until r2 = 0



; draw chars "CC2019" (GG1 used to make inversed CC because lack of "C" in BIOS)
; "1"
	li	20 + xc0	; x
	lr	1,a
	li	yc0			; y
	lr	2,a
	li	$c1
	lr	0,a			; combined color + char index -> r0
	pi	drawchar            

; "G"
	li	12 + xc0	; x
	lr	1,a
	li	$ca
	lr	0,a			; combined color + char index -> r0
	pi	drawchar            

; "G"
	li	17 + xc0	; x
	lr	1,a
	li	$ca
	lr	0,a			; combined color + char index -> r0
	pi	drawchar            

; "2"
	li	24 + xc0	; x
	lr	1,a
	li	$82
	lr	0,a		; combined color + char index -> r0
	pi	drawchar            
; "1"
	li	34 + xc0			; x
	lr	1,a
	li	$81
	lr	0,a		; combined color + char index -> r0
	pi	drawchar            
; "0"
	li	30 + xc0			; x
	lr	1,a
	li	$80
	lr	0,a		; combined color + char index -> r0
	pi	drawchar            
; "9"
	li	38 + xc0			; x
	lr	1,a
	li	$89
	lr	0,a		; combined color + char index -> r0
	pi	drawchar            


AGAIN:

	li	13	; (r0) number of iterations 
	lr	0,a	; a->r0

nextline:

	li	23	; y0
	as	0	;	r0+a->a
	lr	3,a

; set palette for line (y: r3)
;
; 00->125, 00->126: rgb, lightgreen back
; 00->125, ff->126: rgb, lightblue back
; ff->125, 00->126: rgb, transparent (gray) back
; ff->125, ff->126: www, black back


; restore color of lower line  (e.g. 5 with gray back)

	clr				; color (0 -> a)
	lr	1,a

	li	126			; x
	lr	2,a

	pi plot

	li	$ff			; color
	lr	1,a

	ds	2
	pi plot

	lr	a,3		; save r3
	lr	4,a

	ds	3

; change color of upper line  (e.g. 6 with black back)

	li	$ff			; color
	lr	1, a

	li	126			; x
	lr	2, a

	pi plot
	ds	2
	pi plot

;------

; blinking lines


	li	126			; x
	lr	2, a

	li	23			; y
	lr	3, a

	clr				; color
	lr	1, a


	lr	a,8			; color
	lr	1, a
	pi plot

	ds	2

	clr				; color
	lr	1, a
	pi plot

	lr	a,3
	ai 	12			; a+=12	
	lr	3,a

	lr	a,2
	inc
	lr	2,a

	lr	a,8			; color
	lr	1,a
	pi plot

	ds	2

	clr				; color
	lr	1,a
	pi plot

	lr	a,8
	xi	$ff			; change 00 with FF to blink
	lr	8,a



	lr	a,4		; restore r3
	lr	3,a


; setpal end



; delay moving line through the checkerboard

	li	40
	lr	1,a
delay2:          
	li	$ff		
	lr	2,a                
delay1:    
	ds	2                  
	bnz	delay1          
	ds	1
	bnz	delay2            



	ds	0			; r0--
	bnz nextline	; until r0 = 0

; restore top line


; restore color of lower line  (e.g. 5 with gray back)
	ds	3

	clr				; color (0->a)
	lr	1, a

	li	126			; x
	lr	2, a

	pi plot

	li	$ff			; color
	lr	1, a

	ds	2
	pi plot

	li	%11000000   ; 1kHz beep $40 (rather click)
	outs 5
	clr
	outs 5

	jmp	AGAIN

loop:	jmp	loop


; plot point
; r1 = color  $00 = green, $40 = %01000000 = red, $80 = %10000000 = blue, $C0 = %11000000 = background
; r2 = x (to screen) (4-105) (0-101)
; r3 = y (to screen) (4-61) (0-57)

plot:
	; set the color using r1
	lr		A, 1
	outs	1

	; set the column using r2
	lr		A, 2
	com
	outs	4

	; set the row using r3
	lr	A, 3
	com
	outs	5

	; transfer data to the screen memory
	li		$60
	outs	0
	li		$50
	outs	0

	; delay until it's fully updated
	lis	6
.plotDelay:	
	ai	$ff
	bnz	.plotDelay

	pop				; return from the subroutine


	org $fff        ; added only to set a useable rom-size in MESS
	.byte   $ff