[Color Computer] [Coco] ASM Coders - Round two!

James Diffendaffer jdiffendaffer at yahoo.com
Thu Aug 31 01:09:22 EDT 2006


>Another thing that could help novices like David and myself, would be a
>reference type card, which lists the equivalent Basic Rsdos code to 
>what it is in Assembly, and some simple source code.

It's not quite that simple.  Multiple assembly instructions are
required to do the same thing as 1 basic instruction but we could do
this... just now tonight.

>Example, would be the Hscreen2 in Asm, how it is setup, and so forth, 
>For/next loop in basic to it's ASM counterpart Etc, This way someone 
>who is proficient in basic programming, might be inclined to give ASM 
>coding ago.

Well, here is some code to look through that works on older CoCos...
not sure about the 3.  It calls ROM routines so don't expect it to
work if you just change it to a different graphics mode.  You would
need to have CoCo DOS in memory and call the routines for the new
graphics modes.  It runs but I make no promises that everything is
right and I know it isn't optimal since the line routine gets it's
parameters from the stack.
--------------------------------------


* Taken from the December 1988 issue of Rainbow Magazine
* Modified to use EQU to define ROM calls, colors, etc.
* Added high speed poke
* Changed it to use PMODE 4 and then set PMODE 3 to use artifacting	

* COCO ROM entry points
PMODE	EQU	$9628
PAGE	EQU	$9653
PCLS	EQU	$9542
SCREEN	EQU	$95AA
CSET	EQU	$9682
ROMLINE	EQU	$94A1
WAITKEY	EQU	$ADFB
SCALEX1Y1	EQU	$931D
SCALEX2Y2	EQU	$9320


HISPEED	EQU	#65495
LOSPEED	EQU	#65494

* Page zero variables used by COCO DEC BASIC
X1	EQU	$BE
Y1	EQU	$C0
X2	EQU	$C4
Y2	EQU	$C6
COLOR	EQU	$B5
CPMODE	EQU	$B6	;Current PMODE (1 - 4)
GPEND	EQU	$B7	;$B7/$B8 end of graphics page+1
BPLINE	EQU	$B9	;Bytes / line.  #$10 or #$20
GPSTART	EQU	$BA	;$BA/$BB start of graphics page


* color mask definitions
CYAN	EQU	#$55
MAGENTA	EQU	#$AA		
ORANGE	EQU	#$FF


	ORG	$3000

START	STA	HISPEED		;hi speed poke
	LDB	#3		;PMODE 3 or 4
	JSR	PMODE
	LDB	#1		;Page 1
	JSR	PAGE
	JSR	PCLS		;PCLS
	LDB	#1		;GRAPHICS SCREEN
	JSR	SCREEN
;	LDB	#3		;PMODE 3
;	JSR	PMODE
	LDB	#1		;COLOR SET 1
	JSR	CSET

	
COLOR@	LDB	#CYAN
	STB	COLOR
LINE@	CLRB
LOOP@	LDA	#220
	LBSR	SUBT
	PSHS	A		;X1
	LDA	#96
	LBSR	SUBT
	PSHS	A		;Y1
	LDA	#128
	LBSR	SUBT
	PSHS	A		;X2
	LDA	#4
	LBSR	ADN
	PSHS	A		;Y2
	LBSR	LINE
	LEAS	4,S
	ADDB	#4
	CMPB	#92		;END OF LINE 1 YET
	BLS	LOOP@

COLOR@	LDB	#MAGENTA
	STB	COLOR
LINE@	CLRB
LOOP@	LDA	#128
	BSR	SUBT
	PSHS	A		;X1
	LDA	#4
	BSR	ADN
	PSHS	A		;Y1
	LDA	#36
	BSR	ADN
	PSHS	A		;X2
	LDA	#96
	BSR	ADN
	PSHS	A		;Y2
	BSR	LINE
	LEAS	4,S
	ADDB	#4
	CMPB	#92		;END OF LINE2 YET?
	BLS	LOOP@

COLOR@	LDB	#ORANGE		;ORANGE
	STB	COLOR
LINE@	CLRB
LOOP@	LDA	#36
	BSR	ADN
	PSHS	A		;X1
	LDA	#96
	BSR	ADN
	PSHS	A		;Y1
	LDA	#128
	BSR	ADN
	PSHS	A		;X2
	LDA	#188
	BSR	SUBT
	PSHS	A		;Y2
	BSR	LINE
	LEAS	4,S
	ADDB	#4
	CMPB	#92		;END OF LINE3 YET?
	BLS	LOOP@


COLOR@	LDB	#MAGENTA
	STB	COLOR
LINE@	CLRB
LOOP@	LDA	#128
	BSR	ADN
	PSHS	A		;X1
	LDA	#188
	BSR	SUBT
	PSHS	A		;Y1
	LDA	#220
	BSR	SUBT
	PSHS	A		;X2
	LDA	#96
	BSR	SUBT
	PSHS	A		;Y2
	BSR	LINE
	LEAS	4,S
	ADDB	#4
	CMPB	#92		;END OF LINE4 YET?
	BLS	LOOP@

DONE	JSR	WAITKEY		;WAIT FOR INPUT
	CLRB			;TEXT SCREEN
	JSR	SCREEN
	STA	LOSPEED		;normal CPU speed poke
	SWI			;RTS IF IN BASIC
	
SUBT	PSHS	B
	SUBA	,S+
	RTS

ADN	PSHS	B
	ADDA	,S+
	RTS
	
* LINE(X1,Y1,X2,Y2);
* parameters are passed on the stack like C
LINE	PSHS	A,B,X,Y
	LDD	10,S
	STA	Y1
	STB	X1
	LDD	8,S
	STA	Y2
	STB	X2
	JSR	SCALEX1Y1	;SCALE X1 AND Y1
	LDU	#$C3		;START OF X2
	JSR	SCALEX2Y2	;SCALE X2 AND Y2
	JSR	ROMLINE		;DRAW THE LINE(X1,Y1)-(Y2,Y2)
	PULS	A,B,X,Y,PC
	
	END	START






Brought to you by the 6809, the 6803 and their cousins! 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ColorComputer/

<*> To unsubscribe from this group, send an email to:
    ColorComputer-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the Coco mailing list