ENDCODE
;
;
@"
6-38 The Development Library

Example of a Saturn assembly language program using the MASD compiler

"!NO CODE !RPL

*This program display a 131*64 graphic in a pretty way :-)

*DO LCD->, run it, and enjoy!

*This program has been created by Philippe Pamart

::

* remove the menu and test for a grob CK1&Dispatch grob

::

TURNMENUOFF CODE

% R0a: X

% R1a: Y

% R2a: @ grob

SAVE GOSBVL DisableIntr

%

No interrupts

A=DAT1.A D0=A LC 00014 A+C.A R2=A.A

%

adr 1st pixels of the grob

D0+10 A=0.W A=DAT0.10 C=0.W LC 8300040 ?A=C.W % test the size

{ *.End GOSBVL AllowIntr LOADRPL }

%

if not ok, return to RPL

GOSBVL "D0->Row1" D1=A D0-15 C=DAT0.A

C-15.A GOSBVL WIPEOUT % erase screen

LC 0003F R1=C.W

%

initial position in Z

{

 

 

LC 00082

%

we are ready to scan right to left

{

 

 

R0=C.A

%

save the counter

LC 001 GOSBVL OUTCINRTN ?CBIT=1.6

-> .End % If backspace, then stop

GOSUB .PointAndLine

%

test the current point

C=R0.A C-1.A UPNC

%

go one pixel on the right

}

 

 

A=R1.W A-1.A R1=A.A

%

go one line higher

{

%

ready to scan from right to left

LC 001 GOSBVL OUTCINRTN ?CBIT=1.6

-> .End % If backspace, then stop

GOSUB .PointAndLine

%

test the current point

A=R0.A A+1.A R0=A.A LC 83 ?A#C.B UP

% go one pixel on the left

}

 

 

A=R1.A A-1.A R1=A.A UPNC

%

go one line higher (if not finish)

}

 

 

GOTO .End

 

 

*.PointAndLine

%

This tests the current pix, returns

 

%

if the pixel is white, draw a line

 

%

if it is black

A=R1.A A+A.A C=R2.A C+A.A ASL.A A+C.A

%

Aa: @ line of pixel in the grob

C=R0.A P=C.0 CSRB.A CSRB.A A+C.A D0=A

%

D0: point on the pixel to test,

 

%

P = number of the pixel to test in

 

%

nibble (in Z/4Z)

LC 2481248124812481 P=0

%

Cp: pixel mask

A=DAT0.B A&C.P ?A=0.P RTY

%

test the pixel. if white, return

GOSUB LIGNE GOSUB LIGNE

%

else, draw line twice in Xor mode

GOSBVL "D0->Row1" D0-20

%

and draw the pixel in black.

A=R0.A C=R1.A GOVLNG aPixonB

 

 

*LIGNE

 

 

GOSBVL "D0->Row1" D0-20

%

D0 point on the screen

A=R0.A B=A.A LA 00041

 

% A/B: X coordinates

C=R1.A D=C.A C=0.A

 

% C/D: Y coordinates

GOVLNG aLineXor

 

% draw the line!