Aking Posted August 24, 2013 Share Posted August 24, 2013 Many of us are learning assembler with Atariroots it would be great to translate here the main example programs to try on mads like: PROGRAM FOR PRINTING ON THE SCREEN 10 ;20 .TITLE "PRNTSC ROUTINE"30 .PAGE "ROUTINE FOR PRINTING ON THE SCREEN"40 ;50 *=$500060 ;70 BUFLEN=2380 ;0100 EOL=$9B0105 ;0110 OPEN=$030120 OWRIT=$0B0130 PUTCHR=$0B0135 ;0140 IOCB2=$200170 ICCOM=$3420180 ICBAL=$3440190 ICBAH=$3450200 ICBLL=$3480210 ICBLH=$3490220 ICAX1=$34A0230 ICAX2=$34B0235 ;0240 CIOV=$E4560250 ;0260 SCRNAM .BYTE "E:",EOL0270 ;0280 OSCR LDX #IOCB2;OPEN SCREEN ROUTINE0300 LDA #OPEN0310 STA ICCOM,X0320 ;0330 LDA #SCRNAM&2550340 STA ICBAL,X0350 LDA #SCRNAM/2560360 STA ICBAH,X0370 ;0380 LDA #OWRIT0390 STA ICAX1,X0400 LDA #00410 STA ICAX2,X0420 JSR CIOV0430 ;0440 LDA #PUTCHR0450 STA ICCOM,X0460 ;0470 LDA #TXTBUF&2550480 STA ICBAL,X0490 LDA #TXTBUF/2560500 STA ICBAH,X0510 RTS0520 ;0530 PRNT0540 LDX #IOCB20550 LDA #BUFLEN&2550560 STA ICBLL,X0570 LDA #BUFLEN/2560580 STA ICBLH,X0590 JSR CIOV0600 RTS0610 ;0620 TXTBUF=*0630 ;0640 *=*+BUFLEN0650 ;0660 .END THE VISITOR 10 ;20 ; THE VISITOR30 ;35 TXTBUF=$504140 OPNSCR=$500350 PRNTLN=$503170 ;80 *=$60090 ;0100 TEXT .BYTE $54,$41,$4B,$45,$20,$4D,$45,$200110 .BYTE $54,$4F,$20,$59,$4F,$55,$52,$200120 .BYTE $4C,$45,$41,$44,$45,$52,$210130 ;0140 VIZTOR0150 ;0160 LDX #00170 LOOP LDA TEXT,X0180 STA TXTBUF,X0190 INX0200 CPX #230210 BNE LOOP0220 JSR OPNSCR0230 JSR PRNTLN0240 INFIN JMP INFIN all 2 can be combined in one on Mads RESPONSE 10 ;20 ; RESPONSE30 ;40 TXTBUF=$504150 OPNSCR=$503160 PRNTLN=$503170 ;80 EOL=$9b90 ;100 *=$650110 ; 120 TEXT .BYTE "I AM the leader, you fool!",EOL130 ;140 RSPONS150 ;160 LDX #0170 LOOP180 LDA TEXT, X190 STA TXTBUF, X200 CMP #$9B210 BEQ FINI220 INX230 JMP LOOP240 FINI250 JSR OPNSCR260 JSR PRNTLN270 INFIN280 JMP INFIN finally A Demonstration of Fine Scrolling FINESCRL.SRC for the Atari Assembler Editor Cartridge 05 ;10 ;20 ;HELLO SCREEN (FINE)30 ;40 *=$300050 JMP INIT60 ;70 TCKPTR=$200080 FSCPTR=TCKPTR+190 ;0100 SDMCTL=$022F0110 ;0120 SDLSTL=$02300130 SDLSTH=$02310140 ;0150 COLOR0=$02C4;OS COLOR REGISTERS0160 COLOR1=$02C50170 COLOR2=$02C60180 COLOR3=$02C70190 COLOR4=$02C80299 ;0210 HSCROL=$D4040220 ;0230 VVBLKI=$0222; OS INTERRUPT VECTOR0240 SYSVBV=$E45F; INTERRUPT ENABLE VECOTR0250 ;0260 SETVBV=$E45C; SET VERTICAL BLANK INTERRUPT (VBI) VECTOR0270 XITVBV=$E462; EXIT VBI VECTOR0280 ;0290 ; DISPLAY LIST DATA0300 ;0310 START0320 LINE1 .SBYTE " PRESENTING "0330 LINE2 .SBYTE " "0340 .SBYTE " the big program "0350 .SBYTE " "0360 LINE3 .SBYTE " By (You"0370 .SBYTE "r Name) "0380 LINE4 .SBYTE "PLEASE STAND BY "0390 ;0400 ; DISPLAY LIST WITH SCROLLING LINE0410 ;0420 HLIST ;('HELLO' LIST)0430 .BYTE $70, $70, $700440 .BYTE $70,$70,$70,$70,$700450 .BYTE $460460 .WORD LINE10470 ;NOTE THAT THE LAST BYTE IN THE0480 ;NEXT LINE IS $57, NOT $47 AS IT0490 ;WAS IN THE PRECEDING CHAPTER0500 .BYTE $70,$70,$70,$70,$570509 ;THIS THE LINE WE'LL SCROLL0510 SCROLN ;(THIS IS THE LINE WE'LL SCROLL)0520 .WORD $00; A BLANK TO BE FILLD IN LATER0530 .BYTE $70,$420540 .WORD LINE30550 .BYTE $70,$70,$70,$70,$460560 .WORD LINE40570 .BYTE $70,$70,$70,$70,$700580 .BYTE $410590 .WORD HLIST0600 ;0610 ;RUN PROGRAM0620 ;0630 INIT ;PREPARE TO RUN PROGRAM0640 LDA COLOR3; SET COLOR REGISTERS0650 STA COLOR1;0660 LDA COLOR4;0670 STA COLOR2;0680 ;0690 LDA #00700 STA SDMCTL0710 LDA #HLIST&2550720 STA SDLSTL0730 LDA #HLIST/2560740 STA SDLSTH0750 LDA #$220760 STA SDMCTL0770 ;0780 JSR TCKSET; INITIALIZE TICKER ADDRESS0790 ;0800 LDA #40; NUMBER OF CHARACTERS IN SCROLL LINE0810 STA TCKPTR0820 LDA #80830 STA FSCPTR; NUMBER OF CLOR CLOCKS TO FINE SCROLL0840 ;0850 ; ENABLE INTERRUPT0860 ;0870 LDY #TCKINT&2550880 LDX #TCKINT/2560890 LDA #60900 JSR SETVBV0910 ;0920 ; TICKER INTERRUPT0930 ;0940 TCKINT0950 LDA #SCROLL&2550960 STA VVBLKI0970 LDA #SCROLL/2560980 STA VVBLKI+10990 ;1000 INFIN1010 JMP INFIN; INFINITE LOOP1020 ;1030 SCROLL1040 LDX FSCPTR; 8 TO START1050 DEX1060 STX HSCROL1070 BNE CONT1080 LDX #81089 ;CONINUE1090 CONT1100 STX FSCPTR1110 CPX #71120 BEQ COARSE1130 JMP SYSVBV1140 COARSE1150 LDY TCKPTR; NUMBER OF CHARACTERS TO SCROLL1160 DEY1170 BNE SCORSE; LOOP BACK TILL FULL LINE IS SCROLLED1180 LDY #401190 JSR TCKSET; RESET TICKER LINE1199 ;DO COARSE SCROLL1200 SCORSE1210 STY TCKPTR1220 INC SCROLN; LOW BYTE OF ADDRESS1230 BNE RETURN1240 INC SCROLN+1; HIGH BYTE OF ADDRESS1250 RETURN1260 JMP SYSVBV1270 ;1280 TCKSET1290 LDA #LINE2&2551300 STA SCROLN1310 LDA #LINE2/2561320 STA SCROLN+11330 ENDIT1340 RTS Quote Link to comment Share on other sites More sharing options...
pps Posted August 26, 2013 Share Posted August 26, 2013 Just did this and added needed/useful mads code - some of them I commented with extra ## .. ## to find them easier. Thanks to huge features of mads there are some other ways to recode the program ;HELLO SCREEN (FINE) org $3000 JMP INIT TCKPTR=$2000 FSCPTR=TCKPTR+1 SDMCTL=$022F SDLSTL=$0230 ;SDLSTH=$0231 ;## Not really needed in mads ## COLOR0=$02C4 ;OS COLOR REGISTERS COLOR1=$02C5 COLOR2=$02C6 COLOR3=$02C7 COLOR4=$02C8 HSCROL=$D404 VVBLKI=$0222 ; OS INTERRUPT VECTOR SYSVBV=$E45F ; INTERRUPT ENABLE VECOTR SETVBV=$E45C ; SET VERTICAL BLANK INTERRUPT (VBI) VECTOR XITVBV=$E462 ; EXIT VBI VECTOR ; DISPLAY LIST DATA ;START LINE1 dta d' PRESENTING ' LINE2 dta d' ' dta d' the big program ' dta d' ' LINE3 dta d' By (Your Name) ' LINE4 dta d' PLEASE STAND BY ' ; DISPLAY LIST WITH SCROLLING LINE HLIST ;('HELLO' LIST) dta $70, $70, $70 dta $70,$70,$70,$70,$70 dta $46 dta a(LINE1) ;NOTE THAT THE LAST BYTE IN THE ;NEXT LINE IS $57, NOT $47 AS IT ;WAS IN THE PRECEDING CHAPTER dta $70,$70,$70,$70,$57 ;THIS THE LINE WE'LL SCROLL SCROLN ;(THIS IS THE LINE WE'LL SCROLL) dta $00,$00 ; A BLANK TO BE FILLD IN LATER dta $70,$42 dta a(LINE3) dta $70,$70,$70,$70,$46 dta a(LINE4) dta $70,$70,$70,$70,$70 dta $41 dta a(HLIST) ;RUN PROGRAM INIT ;PREPARE TO RUN PROGRAM LDA COLOR3 ; SET COLOR REGISTERS STA COLOR1 LDA COLOR4 STA COLOR2 LDA #0 STA SDMCTL mwa #HLIST SDLSTL ;## sets DL Vector (was line 710 - 740) ## LDA #$22 STA SDMCTL JSR TCKSET ; INITIALIZE TICKER ADDRESS LDA #40 ; NUMBER OF CHARACTERS IN SCROLL LINE STA TCKPTR LDA #8 STA FSCPTR ; NUMBER OF CLOR CLOCKS TO FINE SCROLL ; ENABLE INTERRUPT LDY #TCKINT&255 LDX #TCKINT/256 LDA #6 JSR SETVBV ; TICKER INTERRUPT TCKINT mwa #SCROLL VVBLKI ;## line 950-980 ## INFIN JMP INFIN ; INFINITE LOOP SCROLL LDX FSCPTR ; 8 TO START DEX STX HSCROL BNE CONT LDX #8 ;CONINUE CONT STX FSCPTR CPX #7 BEQ COARSE JMP SYSVBV COARSE LDY TCKPTR ; NUMBER OF CHARACTERS TO SCROLL DEY BNE SCORSE ; LOOP BACK TILL FULL LINE IS SCROLLED LDY #40 JSR TCKSET ; RESET TICKER LINE ;DO COARSE SCROLL SCORSE STY TCKPTR INC SCROLN ; LOW BYTE OF ADDRESS BNE RETURN INC SCROLN+1; HIGH BYTE OF ADDRESS RETURN JMP SYSVBV TCKSET mwa #LINE2 SCROLN ;## line 1290 - 1320 ## ENDIT RTS PS: I did not capitalise the "new" code so you should see the differences, even if I did forget some annotations. 3 Quote Link to comment Share on other sites More sharing options...
Aking Posted August 27, 2013 Author Share Posted August 27, 2013 Just did this and added needed/useful mads code - some of them I commented with extra ## .. ## to find them easier. Thanks to huge features of mads there are some other ways to recode the program ;HELLO SCREEN (FINE) org $3000 JMP INIT TCKPTR=$2000 FSCPTR=TCKPTR+1 SDMCTL=$022F SDLSTL=$0230 ;SDLSTH=$0231 ;## Not really needed in mads ## COLOR0=$02C4 ;OS COLOR REGISTERS COLOR1=$02C5 COLOR2=$02C6 COLOR3=$02C7 COLOR4=$02C8 HSCROL=$D404 VVBLKI=$0222 ; OS INTERRUPT VECTOR SYSVBV=$E45F ; INTERRUPT ENABLE VECOTR SETVBV=$E45C ; SET VERTICAL BLANK INTERRUPT (VBI) VECTOR XITVBV=$E462 ; EXIT VBI VECTOR ; DISPLAY LIST DATA ;START LINE1 dta d' PRESENTING ' LINE2 dta d' ' dta d' the big program ' dta d' ' LINE3 dta d' By (Your Name) ' LINE4 dta d' PLEASE STAND BY ' ; DISPLAY LIST WITH SCROLLING LINE HLIST ;('HELLO' LIST) dta $70, $70, $70 dta $70,$70,$70,$70,$70 dta $46 dta a(LINE1) ;NOTE THAT THE LAST BYTE IN THE ;NEXT LINE IS $57, NOT $47 AS IT ;WAS IN THE PRECEDING CHAPTER dta $70,$70,$70,$70,$57 ;THIS THE LINE WE'LL SCROLL SCROLN ;(THIS IS THE LINE WE'LL SCROLL) dta $00,$00 ; A BLANK TO BE FILLD IN LATER dta $70,$42 dta a(LINE3) dta $70,$70,$70,$70,$46 dta a(LINE4) dta $70,$70,$70,$70,$70 dta $41 dta a(HLIST) ;RUN PROGRAM INIT ;PREPARE TO RUN PROGRAM LDA COLOR3 ; SET COLOR REGISTERS STA COLOR1 LDA COLOR4 STA COLOR2 LDA #0 STA SDMCTL mwa #HLIST SDLSTL ;## sets DL Vector (was line 710 - 740) ## LDA #$22 STA SDMCTL JSR TCKSET ; INITIALIZE TICKER ADDRESS LDA #40 ; NUMBER OF CHARACTERS IN SCROLL LINE STA TCKPTR LDA #8 STA FSCPTR ; NUMBER OF CLOR CLOCKS TO FINE SCROLL ; ENABLE INTERRUPT LDY #TCKINT&255 LDX #TCKINT/256 LDA #6 JSR SETVBV ; TICKER INTERRUPT TCKINT mwa #SCROLL VVBLKI ;## line 950-980 ## INFIN JMP INFIN ; INFINITE LOOP SCROLL LDX FSCPTR ; 8 TO START DEX STX HSCROL BNE CONT LDX #8 ;CONINUE CONT STX FSCPTR CPX #7 BEQ COARSE JMP SYSVBV COARSE LDY TCKPTR ; NUMBER OF CHARACTERS TO SCROLL DEY BNE SCORSE ; LOOP BACK TILL FULL LINE IS SCROLLED LDY #40 JSR TCKSET ; RESET TICKER LINE ;DO COARSE SCROLL SCORSE STY TCKPTR INC SCROLN ; LOW BYTE OF ADDRESS BNE RETURN INC SCROLN+1; HIGH BYTE OF ADDRESS RETURN JMP SYSVBV TCKSET mwa #LINE2 SCROLN ;## line 1290 - 1320 ## ENDIT RTS PS: I did not capitalise the "new" code so you should see the differences, even if I did forget some annotations. thanks !! now how about the player/missile example of the book? : 10 ; 20 ; PLAYER-MISSLE GRAPHICS ROUTINE 30 ; 50 *=$5000 60 JMP START 70 ; 80 RAMTOP=$6A ;TOP OF RAM PTR 90 VVBLKD=$0224 ;INTERRUPT RTN 0100 SDMCTL=$022F ;DMA CNT. SHADOW 0110 SDLSTL=$0230 ;SDLST, LOW BYTE 0120 STICK0=$0278 0130 PCOLR0=$02C0 ;PLAYER COLOR 0140 COLOR2=$02C6 ;BKG COLOR 0150 ; 0160 HPOSP0=$D000 ;PLAYER HORZ PSN 0170 GRACTL=$D01D 0180 PACTL=$D302 ;JS PORT CNTRL 0190 PMBASE=$D407 ;PM BASE ADR 0200 SETVBV=$E45C ;ENABLE INTRPT 0210 XITVBV =$E462 ;EXIT INTERRUPT 0220 ; 0230 HRZPTR=$0600 ;HORIZ PSN PTR 0240 VRTPTR=HRZPTR+1 ;VRT PSN PTR 0250 OURBAS=VRTPTR+1 ;OUR PMBASE 0260 TABSIZ=OURBAS+2 ;TABLE SIZE 0270 FILVAL=TABSIZ+2 ;BLKFIL VALUE 0280 ; 0290 TABPTR=$B0 ;TABLE ADDR PTR 0300 TABADR=TABPTR+2 ;TABLE ADDRESS 0310 ; 0320 PLBOFS=512 ;PLAYER BAS OFFS 0330 PLTOFS=640 ;PLAYER TOP OFFS 0340 ; 0350 SHAPE .BYTE $00,$6C,$FE,$FE,$7C,$38,$10,$00 0360 ; 0370 START 0380 ; 0390 ;CLEAR SCREEN 0400 ; 0410 LDA #0 0420 STA FILVAL 0430 LDA SDLSTL 0440 STA TABPTR 0450 LDA SDLSTL+1 0460 STA TABPTR+1 0470 LDA #960&255 ;BYTES PER SCRN 0480 STA TABSIZ 0490 LDA #960/256 0500 STA TABSIZ+1 0510 JSR BLKFIL 0520 ; 0530 ;DEFINE PMG VARIABLES 0540 ; 0550 LDA #0 0560 STA COLOR2 ;BLACK BKG 0570 LDA #$58 0580 STA PCOLR0 ;PINK PLAYER 0590 ; 0600 LDA #100 ;SET HORIZ PSN 0610 STA HRZPTR 0620 STA HPOSP0 0630 ; 0640 LDA #48 ;SET VERT PSN 0650 STA VRTPTR 0660 ; 0670 LDA #0 ;CLEAR OURBASE 0680 STA OURBAS 0690 STA OURBAS+1 0700 ; 0710 SEC 0720 LDA RAMTOP 0730 SBC #8 0740 STA PMBASE ;BASE=RAMTOP-2K 0750 STA OURBAS+1 ;SAVE BASE ADR 0760 ; 0770 LDA #46 0780 STA SDMCTL ;ENABLE PM DMA 0790 ; 0800 LDA #3 0810 STA GRACTL ;ENABLE PM DSPLY 0820 ; 0830 ;FILL PM RAM W/ZEROS TO CLEAR 0840 ; 0850 CLC 0860 LDA OURBAS 0870 ADC #PLBOFS&255 0880 STA TABADR 0890 STA TABPTR 0900 LDA OURBAS+1 0910 ADC #PLBOFS/256 0920 STA TABADR+1 0930 STA TABPTR+1 0940 ; 0950 SEC 0960 LDA #PLTOFS&255 0970 SBC #PLBOFS&255 0980 STA TABSIZ 0990 LDA #PLTOFS/256 1000 SBC #PLBOFS/256 1010 STA TABSIZ+1 1020 ; 1030 LDA #0 1040 STA FILVAL 1050 JSR BLKFIL 1060 ; 1070 ;DEFINE PLAYER 1080 ; 1090 PLAYER 1100 ; 1110 ;DRAW PLAYER 1120 ; 1130 JSR DRAWPL 1140 ; 1150 ;ENABLE INTERRUPT 1160 ; 1170 LDY #INTRPT&255 1180 LDX #INTRPT/256 1190 LDA #7 1200 JSR SETVBV 1210 ; 1220 INTRPT 1230 LDA #RDSTIK&255 1240 STA VVBLKD 1250 LDA #RDSTIK/256 1260 STA VVBLKD+1 1270 ; 1280 ;INFINITE LOOP 1290 ; 1300 INFIN 1310 JMP INFIN 1320 ; 1330 ;READ JOYSTICK 1340 ; 1350 RDSTIK 1360 LDA #4 1370 ORA PACTL ;SET BIT #5 1380 ; 1390 LDA STICK0 1400 CMP #$F ;JS STRAIGHT UP? 1410 BEQ RETURN ;YES, NO ACTION 1420 ; 1430 TRYAGN 1440 CMP #$07 ;RIGHT MOVE 1450 BNE TRYAG2 1454 STA EYEOFS 1460 LDX HRZPTR 1470 INX 1480 STX HRZPTR 1490 STX HPOSP0 1500 JMP RETURN 1510 ; 1520 TRYAG2 1530 CMP #$0B ;LEFT MOVE 1540 BNE TRYAG3 1550 ; 1560 LDX HRZPTR 1570 DEX 1580 STX HRZPTR 1590 STX HPOSP0 1600 JMP RETURN 1610 ; 1620 TRYAG3 1630 CMP #$0D ;DOWN MOVE 1640 BNE TRYAG4 1650 ; 1660 INC VRTPTR 1670 JSR DRAWPL 1680 JMP RETURN 1690 ; 1700 TRYAG4 1710 CMP #$0E ;UP MOVE 1720 BNE RETURN 1730 ; 1740 DEC VRTPTR 1750 JSR DRAWPL 1760 JMP RETURN 1770 ; 1780 RETURN 1790 JMP XITVBV 1800 ; 1810 ;BLOCK FILL ROUTINE 1820 ; 1830 BLKFIL 1840 ; 1850 ;DO FULL PAGES FIRST 1860 ; 1870 LDA FILVAL 1880 LDX TABSIZ+1 1890 BEQ PARTPG 1900 LDY #0 1910 FULLPG 1920 STA (TABPTR), Y 1930 INY 1940 BNE FULLPG 1950 INC TABPTR+1 1960 DEX 1970 BNE FULLPG 1980 ; 1990 ;DO REMAINING PARTIAL PAGE 2000 ; 2010 PARTPG 2020 LDX TABSIZ 2030 BEQ FINI 2040 LDY #0 2050 ; 2060 PARTLP 2070 STA (TABPTR),Y 2080 INY 2090 DEX 2100 BNE PARTLP 2110 ; 2120 FINI 2130 RTS 2140 ; 2150 DRAWPL 2160 PHA ;SAVE ACC VALUE 2170 CLC 2180 LDA TABADR 2190 ADC VRTPTR 2200 STA TABPTR 2210 LDA TABADR+1 2220 ADC #0 2230 STA TABPTR+1 2240 ; 2250 LDA #0 2260 FILLPL 2270 LDA SHAPE,Y 2280 STA (TABPTR), Y 2290 INY 2300 CPY #8 2310 BCC FILLPL ;REPEAT TILL DONE 2320 PLA ;RESTORE ACC VAL 2330 RTS Quote Link to comment Share on other sites More sharing options...
morelenmir Posted August 27, 2013 Share Posted August 27, 2013 I think it also depends how 'authentic' you want your MADS code to be. There isn't really a LOT that needs changing, other than "*=" to "ORG". BYTE, WORD and so forth work the same, even though the correct MADS constant definition directives are 'dta' or whichever. There are also high level refinements which assembler-specific directives allow - like cobbling together a local variable system and more C-style function definitions. I personally stay away from these constructs like the plague. Firstly I want the code I produce to be as assembler-agnostic as possible and secondly I have this stupid bee in my bonnet about the more advanced features of MADS and other modern assemblers being 'cheating'. At the very least I want to learn how to do these things 'properly' before starting to lean on the many attractive crutches that MADS offers. Admittedly I am also a colossal hypocrite as you won't hear me moaning about the automatic 'SBYTE'-alike functionality that MADS brings to BYTE directives! Ideally my approach is to produce code that will assemble on "Atari Assembler Editor" cartridge with an absolute minimum of alteration, but still work in the luxury environment of the Eclipse+WUDSN IDE combination with MADS to do the cross-compiling. Quote Link to comment Share on other sites More sharing options...
toad Posted August 27, 2013 Share Posted August 27, 2013 (edited) I think it's awesome that you are redoing this example code in MADS. I am coding with Atari Assembler Editor - precisely because it's an easy 'in' to programming the Atari, with a wealth of documentation using the Atari Assembler Editor format - I just couldn't ignore that as being a strength of using Atari Assembler Editor as a noob way of learning assembler. However it has its drawbacks - namely 1. the Editor, and 2. The Assembler - lol. Yeah. But what I do for now, is I edit in Text Wrangler. That gives me a modern editor. I can use all of its features - and the main thing, is the code looks nice with plenty of spaces, comments, and no line #s. Then a script just changes back into Atari Assembler Editor format. (I mean you can add line #'s with a simple "cat -n" command, but it ended up being slightly more complicated than just that) - that took care of the worst issues I had with "editing". Then, to solve the problem of the "Assembler" I just use Altirra in a virtualbox and select "Warp Speed" - which makes it considerably faster for compiling the code - originally I was using Atari800MacX, but Altirra is faster, I think. although, yeah, I guess you still have the issue of the assembler cart taking its own memory. Better to have a cross assembler. From my perspective as a newbie, Atari Editor Assembler really did help me get started quickly - but I could imagine if documentation was just readily for this WUDSN/mads solution... available especially with a tutorial website, I would have probably been drawn to that instead. Edited August 27, 2013 by toad 1 Quote Link to comment Share on other sites More sharing options...
Aking Posted August 27, 2013 Author Share Posted August 27, 2013 I think it's awesome that you are redoing this example code in MADS. I am coding with Atari Assembler Editor - precisely because it's an easy 'in' to programming the Atari, with a wealth of documentation using the Atari Assembler Editor format - I just couldn't ignore that as being a strength of using Atari Assembler Editor as a noob way of learning assembler. However it has its drawbacks - namely 1. the Editor, and 2. The Assembler - lol. Yeah. But what I do for now, is I edit in Text Wrangler. That gives me a modern editor. I can use all of its features - and the main thing, is the code looks nice with plenty of spaces, comments, and no line #s. Then a script just changes back into Atari Assembler Editor format. (I mean you can add line #'s with a simple "cat -n" command, but it ended up being slightly more complicated than just that) - that took care of the worst issues I had with "editing". Then, to solve the problem of the "Assembler" I just use Altirra in a virtualbox and select "Warp Speed" - which makes it considerably faster for compiling the code - originally I was using Atari800MacX, but Altirra is faster, I think. although, yeah, I guess you still have the issue of the assembler cart taking its own memory. Better to have a cross assembler. From my perspective as a newbie, Atari Editor Assembler really did help me get started quickly - but I could imagine if documentation was just readily for this WUDSN/mads solution... available especially with a tutorial website, I would have probably been drawn to that instead. to install the "WUDSN/mads solution" i used these: Quote Link to comment Share on other sites More sharing options...
Aking Posted August 27, 2013 Author Share Posted August 27, 2013 I think it also depends how 'authentic' you want your MADS code to be. There isn't really a LOT that needs changing, other than "*=" to "ORG". BYTE, WORD and so forth work the same, even though the correct MADS constant definition directives are 'dta' or whichever. There are also high level refinements which assembler-specific directives allow - like cobbling together a local variable system and more C-style function definitions. I personally stay away from these constructs like the plague. Firstly I want the code I produce to be as assembler-agnostic as possible and secondly I have this stupid bee in my bonnet about the more advanced features of MADS and other modern assemblers being 'cheating'. At the very least I want to learn how to do these things 'properly' before starting to lean on the many attractive crutches that MADS offers. Admittedly I am also a colossal hypocrite as you won't hear me moaning about the automatic 'SBYTE'-alike functionality that MADS brings to BYTE directives! Ideally my approach is to produce code that will assemble on "Atari Assembler Editor" cartridge with an absolute minimum of alteration, but still work in the luxury environment of the Eclipse+WUDSN IDE combination with MADS to do the cross-compiling. ; ; PLAYER-MISSLE GRAPHICS ROUTINE ; ORG=$5000 JMP START ; RAMTOP=$6A ;TOP OF RAM PTR VVBLKD=$0224 ;INTERRUPT RTN SDMCTL=$022F ;DMA CNT. SHADOW SDLSTL=$0230 ;SDLST, LOW BYTE STICK0=$0278 PCOLR0=$02C0 ;PLAYER COLOR COLOR2=$02C6 ;BKG COLOR ; HPOSP0=$D000 ;PLAYER HORZ PSN GRACTL=$D01D PACTL=$D302 ;JS PORT CNTRL PMBASE=$D407 ;PM BASE ADR SETVBV=$E45C ;ENABLE INTRPT XITVBV =$E462 ;EXIT INTERRUPT ; HRZPTR=$0600 ;HORIZ PSN PTR VRTPTR=HRZPTR+1 ;VRT PSN PTR OURBAS=VRTPTR+1 ;OUR PMBASE TABSIZ=OURBAS+2 ;TABLE SIZE FILVAL=TABSIZ+2 ;BLKFIL VALUE ; TABPTR=$B0 ;TABLE ADDR PTR TABADR=TABPTR+2 ;TABLE ADDRESS ; PLBOFS=512 ;PLAYER BAS OFFS PLTOFS=640 ;PLAYER TOP OFFS ; SHAPE dta $00,$6C,$FE,$FE,$7C,$38,$10,$00 getting and error here ; START ; ;CLEAR SCREEN ; LDA #0 STA FILVAL LDA SDLSTL STA TABPTR LDA SDLSTL+1 STA TABPTR+1 LDA #960&255 ;BYTES PER SCRN STA TABSIZ LDA #960/256 STA TABSIZ+1 JSR BLKFIL ; ;DEFINE PMG VARIABLES ; LDA #0 STA COLOR2 ;BLACK BKG LDA #$58 STA PCOLR0 ;PINK PLAYER ; LDA #100 ;SET HORIZ PSN STA HRZPTR STA HPOSP0 ; LDA #48 ;SET VERT PSN STA VRTPTR ; LDA #0 ;CLEAR OURBASE STA OURBAS STA OURBAS+1 ; SEC LDA RAMTOP SBC #8 STA PMBASE ;BASE=RAMTOP-2K STA OURBAS+1 ;SAVE BASE ADR ; LDA #46 STA SDMCTL ;ENABLE PM DMA ; LDA #3 STA GRACTL ;ENABLE PM DSPLY ; ;FILL PM RAM W/ZEROS TO CLEAR ; CLC LDA OURBAS ADC #PLBOFS&255 STA TABADR STA TABPTR LDA OURBAS+1 ADC #PLBOFS/256 STA TABADR+1 STA TABPTR+1 ; SEC LDA #PLTOFS&255 SBC #PLBOFS&255 STA TABSIZ LDA #PLTOFS/256 SBC #PLBOFS/256 STA TABSIZ+1 ; LDA #0 STA FILVAL JSR BLKFIL ; ;DEFINE PLAYER ; PLAYER ; ;DRAW PLAYER ; JSR DRAWPL ; ;ENABLE INTERRUPT ; LDY #INTRPT&255 LDX #INTRPT/256 LDA #7 JSR SETVBV ; INTRPT LDA #RDSTIK&255 STA VVBLKD LDA #RDSTIK/256 STA VVBLKD+1 ; ;INFINITE LOOP ; INFIN JMP INFIN ; ;READ JOYSTICK ; RDSTIK LDA #4 ORA PACTL ;SET BIT #5 ; LDA STICK0 CMP #$F ;JS STRAIGHT UP? BEQ RETURN ;YES, NO ACTION ; TRYAGN CMP #$07 ;RIGHT MOVE BNE TRYAG2 STA EYEOFS LDX HRZPTR INX STX HRZPTR STX HPOSP0 JMP RETURN ; TRYAG2 CMP #$0B ;LEFT MOVE BNE TRYAG3 ; LDX HRZPTR DEX STX HRZPTR STX HPOSP0 JMP RETURN ; TRYAG3 CMP #$0D ;DOWN MOVE BNE TRYAG4 ; INC VRTPTR JSR DRAWPL JMP RETURN ; TRYAG4 CMP #$0E ;UP MOVE BNE RETURN ; DEC VRTPTR JSR DRAWPL JMP RETURN ; RETURN JMP XITVBV ; ;BLOCK FILL ROUTINE ; BLKFIL ; ;DO FULL PAGES FIRST ; LDA FILVAL LDX TABSIZ+1 BEQ PARTPG LDY #0 FULLPG STA (TABPTR), Y INY BNE FULLPG INC TABPTR+1 DEX BNE FULLPG ; ;DO REMAINING PARTIAL PAGE ; PARTPG LDX TABSIZ BEQ FINI LDY #0 ; PARTLP STA (TABPTR),Y INY DEX BNE PARTLP ; FINI RTS ; DRAWPL PHA ;SAVE ACC VALUE CLC LDA TABADR ADC VRTPTR STA TABPTR LDA TABADR+1 ADC #0 STA TABPTR+1 ; LDA #0 FILLPL LDA SHAPE,Y STA (TABPTR), Y INY CPY #8 BCC FILLPL ;REPEAT TILL DONE PLA ;RESTORE ACC VAL RTS Quote Link to comment Share on other sites More sharing options...
morelenmir Posted August 28, 2013 Share Posted August 28, 2013 Interestingly, after copying and pasting that in to WUDSN and attempting to assemble with MADS I don't get a problem with: SHAPE dta $00,$6C,$FE,$FE,$7C,$38,$10,$00 Which seems to assemble fine. However the assembler DOES complain about: STA EYEOFS As 'EYEOFS' has not been declared. Is it a typo? Quote Link to comment Share on other sites More sharing options...
AtariGeezer Posted August 28, 2013 Share Posted August 28, 2013 Just did this and added needed/useful mads code - some of them I commented with extra ## .. ## to find them easier. Thanks to huge features of mads there are some other ways to recode the program Attachments not working? Quote Link to comment Share on other sites More sharing options...
Aking Posted August 28, 2013 Author Share Posted August 28, 2013 (edited) Attachments not working? you have to clear your browser's cache for them to work please re upload Edited August 28, 2013 by Aking Quote Link to comment Share on other sites More sharing options...
pps Posted August 28, 2013 Share Posted August 28, 2013 Hmm, this seems to be bugged by the new forum update... here we go again: roots1.asm roots1.xex Quote Link to comment Share on other sites More sharing options...
+Allan Posted August 28, 2013 Share Posted August 28, 2013 Hmm, this seems to be bugged by the new forum update... Your new attachments are working. Allan Quote Link to comment Share on other sites More sharing options...
Aking Posted August 28, 2013 Author Share Posted August 28, 2013 Hmm, this seems to be bugged by the new forum update... here we go again: roots1.asm roots1.xex that one was already solved (thanks to you) we need help with this one on mads ; ; PLAYER-MISSLE GRAPHICS ROUTINE ; ORG=$5000 JMP START ; RAMTOP=$6A ;TOP OF RAM PTR VVBLKD=$0224 ;INTERRUPT RTN SDMCTL=$022F ;DMA CNT. SHADOW SDLSTL=$0230 ;SDLST, LOW BYTE STICK0=$0278 PCOLR0=$02C0 ;PLAYER COLOR COLOR2=$02C6 ;BKG COLOR ; HPOSP0=$D000 ;PLAYER HORZ PSN GRACTL=$D01D PACTL=$D302 ;JS PORT CNTRL PMBASE=$D407 ;PM BASE ADR SETVBV=$E45C ;ENABLE INTRPT XITVBV =$E462 ;EXIT INTERRUPT ; HRZPTR=$0600 ;HORIZ PSN PTR VRTPTR=HRZPTR+1 ;VRT PSN PTR OURBAS=VRTPTR+1 ;OUR PMBASE TABSIZ=OURBAS+2 ;TABLE SIZE FILVAL=TABSIZ+2 ;BLKFIL VALUE ; TABPTR=$B0 ;TABLE ADDR PTR TABADR=TABPTR+2 ;TABLE ADDRESS ; PLBOFS=512 ;PLAYER BAS OFFS PLTOFS=640 ;PLAYER TOP OFFS ; SHAPE dta $00,$6C,$FE,$FE,$7C,$38,$10,$00 ; START ; ;CLEAR SCREEN ; LDA #0 STA FILVAL LDA SDLSTL STA TABPTR LDA SDLSTL+1 STA TABPTR+1 LDA #960&255 ;BYTES PER SCRN STA TABSIZ LDA #960/256 STA TABSIZ+1 JSR BLKFIL ; ;DEFINE PMG VARIABLES ; LDA #0 STA COLOR2 ;BLACK BKG LDA #$58 STA PCOLR0 ;PINK PLAYER ; LDA #100 ;SET HORIZ PSN STA HRZPTR STA HPOSP0 ; LDA #48 ;SET VERT PSN STA VRTPTR ; LDA #0 ;CLEAR OURBASE STA OURBAS STA OURBAS+1 ; SEC LDA RAMTOP SBC #8 STA PMBASE ;BASE=RAMTOP-2K STA OURBAS+1 ;SAVE BASE ADR ; LDA #46 STA SDMCTL ;ENABLE PM DMA ; LDA #3 STA GRACTL ;ENABLE PM DSPLY ; ;FILL PM RAM W/ZEROS TO CLEAR ; CLC LDA OURBAS ADC #PLBOFS&255 STA TABADR STA TABPTR LDA OURBAS+1 ADC #PLBOFS/256 STA TABADR+1 STA TABPTR+1 ; SEC LDA #PLTOFS&255 SBC #PLBOFS&255 STA TABSIZ LDA #PLTOFS/256 SBC #PLBOFS/256 STA TABSIZ+1 ; LDA #0 STA FILVAL JSR BLKFIL ; ;DEFINE PLAYER ; PLAYER ; ;DRAW PLAYER ; JSR DRAWPL ; ;ENABLE INTERRUPT ; LDY #INTRPT&255 LDX #INTRPT/256 LDA #7 JSR SETVBV ; INTRPT LDA #RDSTIK&255 STA VVBLKD LDA #RDSTIK/256 STA VVBLKD+1 ; ;INFINITE LOOP ; INFIN JMP INFIN ; ;READ JOYSTICK ; RDSTIK LDA #4 ORA PACTL ;SET BIT #5 ; LDA STICK0 CMP #$F ;JS STRAIGHT UP? BEQ RETURN ;YES, NO ACTION ; TRYAGN CMP #$07 ;RIGHT MOVE BNE TRYAG2 STA EYEOFS LDX HRZPTR INX STX HRZPTR STX HPOSP0 JMP RETURN ; TRYAG2 CMP #$0B ;LEFT MOVE BNE TRYAG3 ; LDX HRZPTR DEX STX HRZPTR STX HPOSP0 JMP RETURN ; TRYAG3 CMP #$0D ;DOWN MOVE BNE TRYAG4 ; INC VRTPTR JSR DRAWPL JMP RETURN ; TRYAG4 CMP #$0E ;UP MOVE BNE RETURN ; DEC VRTPTR JSR DRAWPL JMP RETURN ; RETURN JMP XITVBV ; ;BLOCK FILL ROUTINE ; BLKFIL ; ;DO FULL PAGES FIRST ; LDA FILVAL LDX TABSIZ+1 BEQ PARTPG LDY #0 FULLPG STA (TABPTR), Y INY BNE FULLPG INC TABPTR+1 DEX BNE FULLPG ; ;DO REMAINING PARTIAL PAGE ; PARTPG LDX TABSIZ BEQ FINI LDY #0 ; PARTLP STA (TABPTR),Y INY DEX BNE PARTLP ; FINI RTS ; DRAWPL PHA ;SAVE ACC VALUE CLC LDA TABADR ADC VRTPTR STA TABPTR LDA TABADR+1 ADC #0 STA TABPTR+1 ; LDA #0 FILLPL LDA SHAPE,Y STA (TABPTR), Y INY CPY #8 BCC FILLPL ;REPEAT TILL DONE PLA ;RESTORE ACC VAL RTS Quote Link to comment Share on other sites More sharing options...
pps Posted August 29, 2013 Share Posted August 29, 2013 @toad: Using mads is a straight way for me, cause when I started again coding for the atari (around 1999), I wanted to do it using the modern hardware. I found a tool, that nowadays is much more, than it's name says: graph2font. The version (2.x if I remember correct) was the right tool for doing some font conversations of pictures on the pc. It creates some asm source for XASM. So I used an editor to get my own code together with this outputs. Later g2f outputs changed to mads - XASM is in sleep mode for a long time. So I went there too - even if I use many of the "old" XASM ways to code - glad enough mads supports them - it's something like a upgraded XASM. Then JAC! came back to the scene and brought the WUDSN (maybe he've never been away, but slept for a while ). For me, the most powerful ide for our beloved 8bit. My choice to code for atari nowadays: Modern pc with WUDSN, mads & g2f & altirra & rmt & a good file commander (I use Altap Salamander) btt: When changing the given sources of atari roots to mads not that much is to do. 1st: get rid of the line numbers 2nd: *=$xxxx -> org $xxxx 3rd: LDA #RDSTIK&255STA VVBLKDLDA #RDSTIK/256STA VVBLKD+1 can become mwa #RDSTIK VVBLKD less to write LDA xx sta yyyy can be mva xx yyyy 4th: #XXXXXXX&255 -> #<XXXXXXX 5th: #XXXXXXX/256 -> #>XXXXXXX 6th: don't forget to run START (or which label is used) to compile a starting programm - jmp $XXXX at the start can be left then, but it's not a must. 7th: .word or .byte can be changed to dta and dta a(), but might not as they're implemented in mads too 4th & 5th might be not needed. Never tested that, cause I'm a coder, so I always want to have less to type, so /256 or &255 is no choice for me, as it can be > or < This should been all the magic differences. About the pm example: There might be an error caused by the digitalization: ... CMP #$07 ;RIGHT MOVEBNE TRYAG2STA EYEOFSLDX HRZPTR ... Can't see any EYEOFS in the definition part. Someone with the original book might have a look about this issue. Quote Link to comment Share on other sites More sharing options...
tep392 Posted August 29, 2013 Share Posted August 29, 2013 that one was already solved (thanks to you) we need help with this one on mads ; ; PLAYER-MISSLE GRAPHICS ROUTINE ; ORG=$5000 JMP START ; RAMTOP=$6A ;TOP OF RAM PTR VVBLKD=$0224 ;INTERRUPT RTN SDMCTL=$022F ;DMA CNT. SHADOW SDLSTL=$0230 ;SDLST, LOW BYTE STICK0=$0278 PCOLR0=$02C0 ;PLAYER COLOR COLOR2=$02C6 ;BKG COLOR ; HPOSP0=$D000 ;PLAYER HORZ PSN GRACTL=$D01D PACTL=$D302 ;JS PORT CNTRL PMBASE=$D407 ;PM BASE ADR SETVBV=$E45C ;ENABLE INTRPT XITVBV =$E462 ;EXIT INTERRUPT ; HRZPTR=$0600 ;HORIZ PSN PTR VRTPTR=HRZPTR+1 ;VRT PSN PTR OURBAS=VRTPTR+1 ;OUR PMBASE TABSIZ=OURBAS+2 ;TABLE SIZE FILVAL=TABSIZ+2 ;BLKFIL VALUE ; TABPTR=$B0 ;TABLE ADDR PTR TABADR=TABPTR+2 ;TABLE ADDRESS ; PLBOFS=512 ;PLAYER BAS OFFS PLTOFS=640 ;PLAYER TOP OFFS ; SHAPE dta $00,$6C,$FE,$FE,$7C,$38,$10,$00 ; START ; ;CLEAR SCREEN ; LDA #0 STA FILVAL LDA SDLSTL STA TABPTR LDA SDLSTL+1 STA TABPTR+1 LDA #960&255 ;BYTES PER SCRN STA TABSIZ LDA #960/256 STA TABSIZ+1 JSR BLKFIL ; ;DEFINE PMG VARIABLES ; LDA #0 STA COLOR2 ;BLACK BKG LDA #$58 STA PCOLR0 ;PINK PLAYER ; LDA #100 ;SET HORIZ PSN STA HRZPTR STA HPOSP0 ; LDA #48 ;SET VERT PSN STA VRTPTR ; LDA #0 ;CLEAR OURBASE STA OURBAS STA OURBAS+1 ; SEC LDA RAMTOP SBC #8 STA PMBASE ;BASE=RAMTOP-2K STA OURBAS+1 ;SAVE BASE ADR ; LDA #46 STA SDMCTL ;ENABLE PM DMA ; LDA #3 STA GRACTL ;ENABLE PM DSPLY ; ;FILL PM RAM W/ZEROS TO CLEAR ; CLC LDA OURBAS ADC #PLBOFS&255 STA TABADR STA TABPTR LDA OURBAS+1 ADC #PLBOFS/256 STA TABADR+1 STA TABPTR+1 ; SEC LDA #PLTOFS&255 SBC #PLBOFS&255 STA TABSIZ LDA #PLTOFS/256 SBC #PLBOFS/256 STA TABSIZ+1 ; LDA #0 STA FILVAL JSR BLKFIL ; ;DEFINE PLAYER ; PLAYER ; ;DRAW PLAYER ; JSR DRAWPL ; ;ENABLE INTERRUPT ; LDY #INTRPT&255 LDX #INTRPT/256 LDA #7 JSR SETVBV ; INTRPT LDA #RDSTIK&255 STA VVBLKD LDA #RDSTIK/256 STA VVBLKD+1 ; ;INFINITE LOOP ; INFIN JMP INFIN ; ;READ JOYSTICK ; RDSTIK LDA #4 ORA PACTL ;SET BIT #5 ; LDA STICK0 CMP #$F ;JS STRAIGHT UP? BEQ RETURN ;YES, NO ACTION ; TRYAGN CMP #$07 ;RIGHT MOVE BNE TRYAG2 STA EYEOFS LDX HRZPTR INX STX HRZPTR STX HPOSP0 JMP RETURN ; TRYAG2 CMP #$0B ;LEFT MOVE BNE TRYAG3 ; LDX HRZPTR DEX STX HRZPTR STX HPOSP0 JMP RETURN ; TRYAG3 CMP #$0D ;DOWN MOVE BNE TRYAG4 ; INC VRTPTR JSR DRAWPL JMP RETURN ; TRYAG4 CMP #$0E ;UP MOVE BNE RETURN ; DEC VRTPTR JSR DRAWPL JMP RETURN ; RETURN JMP XITVBV ; ;BLOCK FILL ROUTINE ; BLKFIL ; ;DO FULL PAGES FIRST ; LDA FILVAL LDX TABSIZ+1 BEQ PARTPG LDY #0 FULLPG STA (TABPTR), Y INY BNE FULLPG INC TABPTR+1 DEX BNE FULLPG ; ;DO REMAINING PARTIAL PAGE ; PARTPG LDX TABSIZ BEQ FINI LDY #0 ; PARTLP STA (TABPTR),Y INY DEX BNE PARTLP ; FINI RTS ; DRAWPL PHA ;SAVE ACC VALUE CLC LDA TABADR ADC VRTPTR STA TABPTR LDA TABADR+1 ADC #0 STA TABPTR+1 ; LDA #0 FILLPL LDA SHAPE,Y STA (TABPTR), Y INY CPY #8 BCC FILLPL ;REPEAT TILL DONE PLA ;RESTORE ACC VAL RTS I'm going to teach you what needs to be done with this one and let you do the work your self. This will help reinforce what you have learned. 1) remove the = from the org statement ORG=$5000 ORG $5000 2) All labels should start in column 1. ex. RAMTOP=$6A RAMTOP=$6a START START 3) This line seems to be a bug. EYEOFS is not defined. Looking at the code, I don't know what it would even be used for. It doen't seem to be needed for the joystick input code. You might try just removing it and see if the code runs correctly. STA EYEOFS edit: I just assembled this with MADS. I removed STA EYEOFS and it worked fine. FYI, the command line I used was: mads sample.asm -o:sample.xex -l:sample.lst Quote Link to comment Share on other sites More sharing options...
Aking Posted September 5, 2013 Author Share Posted September 5, 2013 @tep392 the purpose of this thread is to help all people going through the Atariroots / WUDSN/mads solution @pps thank you very much so, then , here's the last program of the book Quote Link to comment Share on other sites More sharing options...
tep392 Posted September 5, 2013 Share Posted September 5, 2013 @tep392 the purpose of this thread is to help all people going through the Atariroots / WUDSN/mads solution Of course. Quote Link to comment Share on other sites More sharing options...
funkheld Posted September 11, 2013 Share Posted September 11, 2013 Hello, on Error with : pmis.xex The Disk DOS 2.5 : Select Itim or Return For Menu Why is this ? Greeting Quote Link to comment Share on other sites More sharing options...
Aking Posted September 17, 2013 Author Share Posted September 17, 2013 works fine on real hardware with side loader Quote Link to comment Share on other sites More sharing options...
Aking Posted December 27, 2013 Author Share Posted December 27, 2013 Hello, on Error with : pmis.xex The Disk DOS 2.5 : Select Itim or Return For Menu Why is this ? Greeting move the joystick to see the heart otherwise you will only notice a black screen Quote Link to comment Share on other sites More sharing options...
Aking Posted January 9, 2014 Author Share Posted January 9, 2014 if anyone is interested in more book programs translated to MADS code, please PM me Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.