Example of a Saturn assembly language program using the MASD compiler
"!NO CODE !RPL
*This program display a 131*64 graphic in a pretty
*DO
*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 | ||
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 | ||
GOSUB .PointAndLine | % | test the current point |
C=R0.A | % | go one pixel on the right |
} |
|
|
A=R1.W | % | go one line higher |
{ | % | ready to scan from right to left |
LC 001 GOSBVL OUTCINRTN ?CBIT=1.6 | ||
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 | % | 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 | % | and draw the pixel in black. |
A=R0.A C=R1.A GOVLNG aPixonB |
|
|
*LIGNE |
|
|
GOSBVL | % | 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! |