Aces123 Posted September 14, 2014 Share Posted September 14, 2014 Hi! I am playing around with this Hello World program in MADS. Unfourtnatley I don't remeber where I found it. Anyway how do I change the color of the text? Maybe someone can explain what the different lines of code do? And where the code differs from the Atari Assembler cartridge? Here is the code: ; "Hello world" in 6502 assembly language for 8-bit Atari. ; Assembler: http://xasm.atari.org/ or http://mads.atari8.info/ org $3000 main lda #$21 sta $22f lda #<dl sta $230 lda #>dl sta $231 jmp * text dta d' HELLO, ',d'WORLD! '* ; Display List dl dta b($70),b($70),b($70),b($47),a(text),b($41),a(dl) org $2e0 dta a(main) end Quote Link to comment Share on other sites More sharing options...
Rybags Posted September 14, 2014 Share Posted September 14, 2014 You can change text by manipulating the colour registers, usual method is change the shadow registers in RAM. The example you have uses Antic Mode 7 aka Graphics 2 which allows 4 colours for the displayed text. The high 2 bits of the character codes determine which colour is selected for each character. In Basic you'd normally select text colour by having the text as either caps/lower case, inverse video or not. For the alpha chars that is sufficient to select the colour per character. For the numerals and available special characters, the inverse bit works but the alternate characters to get the other 2 colours are different. Not sure with MADS, some assemblers have .byte or dta directive that allows adding a fixed constant to the text, you could use that with $40,$80,$C0 to get the extra colour selections. Quote Link to comment Share on other sites More sharing options...
Aces123 Posted September 14, 2014 Author Share Posted September 14, 2014 Thanks for your help. I am a total noob at assembly so could you dumb down the explanation What lines could I change in the actual code to say change the orange text to something else? Quote Link to comment Share on other sites More sharing options...
Rybags Posted September 14, 2014 Share Posted September 14, 2014 Change the text from upper to lower case. I don't have any MADS reference handy, so can't describe the other method of adding values to text strings. Quote Link to comment Share on other sites More sharing options...
Aces123 Posted September 14, 2014 Author Share Posted September 14, 2014 Thanks! I changed the text to lower case and it actually changed the color of hello to lime and the color of world to violet. I wonder why hello and world are in different colors though? Ah the mysteries of assembler Quote Link to comment Share on other sites More sharing options...
pps Posted September 14, 2014 Share Posted September 14, 2014 here we go... Hi! I am playing around with this Hello World program in MADS. Unfourtnatley I don't remeber where I found it. Anyway how do I change the color of the text? Maybe someone can explain what the different lines of code do? And where the code differs from the Atari Assembler cartridge? Here is the code: ; "Hello world" in 6502 assembly language for 8-bit Atari. ; Assembler: http://xasm.atari.org/ or http://mads.atari8.info/ org $3000 ; Start address of your code, should be between $2000 and $a000 to be sure it loads from most DOS main lda #$21 ; main is a label sta $22f ; write #$21 into $22f -> DMA on lda #<dl ; load low part of the address of label dl into accumulator sta $230 ; write it into the low part of DL vector lda #>dl ; now go for the high part of dl sta $231 ; write it into the high part of DL vector jmp * ; endless jump to itselves text dta d' HELLO, ',d'WORLD! '* ; text is label; dta d writes things between ' ' into memory the star at the end is for adding 128 to each char, ; so WORLD! becomes another colour. Try: dta d' HeLlO, ',d'WoRlD! '* ; Display List dl dta b($70),b($70),b($70),b($47),a(text),b($41),a(dl) ; dl is label used in the upper code, $70 := 8 blank lines (or a full char line), ; $47 := load memory address and set to charmode like BASIC GR. 2, ; a(text) := store the address of text here, ; b($41),a(dl) := ANTIC needs to know that the dl is over and where the start is for next run org $2e0 ; following code will be compiled to $2e0 (RUN address of a compiled programme) dta a(main) ; at least we have to set it to main end There are several things, that could be done in other ways on MADS. So the Code could look like this, too: ; "Hello world" in 6502 assembly language for 8-bit Atari. ; Assembler: http://xasm.atari.or...ds.atari8.info/ ; shorter version using MADS opcodes org $3000 main lda #$21 sta $22f mwa #dl $230 jmp * text dta d' HELLO, ',d'WORLD! '* ; Display List dl dta $70,$70,$70,$47,a(text),$41,a(dl) run main end Here it is hard to read, where the labels are. To have it better for the eyes - and to have better error research - I always write my code with tabs before asm and no tabs before a label e.g. ; quick and dirty specnotes - january 2011 - pps hposp0 = $D000 hposp1 = $D001 hposp2 = $D002 hposp3 = $D003 hposm0 = $D004 hposm1 = $D005 hposm2 = $D006 hposm3 = $D007 sizep0 = $D008 sizep1 = $D009 sizep2 = $D00A sizep3 = $D00B sizem = $D00C colpm0 = $D012 colpm1 = $D013 colpm2 = $D014 colpm3 = $D015 color0 = $D016 color1 = $D017 color2 = $D018 color3 = $D019 colbak = $D01A gtictl = $D01B pmcntl = $D01D hitclr = $D01E skctl = $D20F portb = $D301 dmactl = $D400 dlptr = $D402 vscrol = $D405 pmbase = $D407 chbase = $D409 wsync = $D40A vcount = $D40B nmien = $D40E nmist = $D40F * --- MAIN PROGRAM org $a000 ant dta $70,$70,$70,$70,$70,$f0,$42,a(scr),$70 dta $02,$0,$02,$40,$02,$0,$02,$0,$02,$0,$02,$0,$02,$0,$02,$0,$02,$0,$02 dta $40,$02 dta $41,a(ant) mainload mwa #ant 560 ;DL an mwa #dli 512 ;dann neuen eintragen lda #7 ;VBI ldx >vbi ;wird ldy <vbi ;jetzt jsr $e45c ;angeschaltet mva #$c0 $d40e ;und an mva #$ff skctl l lda skctl cmp #$ff beq l jmp $e477 c1 dta 0 ;aim $06 c2 dta 0 ;aim $0e ;---------------------------------------------------- dli pha tya pha txa pha lda #$E0 sta chbase lda #$00 sta colbak lda c1 sta color1 lda c2 sta color2 sta wsync pla tax pla tay pla rti ;----- dli2 pha tya pha txa pha lda #$E0 sta chbase lda #$00 sta colbak lda #$0e sta color2 lda #$06 sta color1 ldx #0 l1 sta wsync inx cpx zaehl bne l1 ldx #$06 stx color1 stx wsync inx stx color1 stx wsync inx stx color1 stx wsync inx stx color1 stx wsync inx stx color1 stx wsync inx stx color1 stx wsync inx stx color1 stx wsync inx stx color1 stx wsync inx stx color1 stx wsync pla tax pla tay pla rti ;----- dli3 pha tya pha txa pha lda #$E0 sta chbase lda #$00 sta colbak lda #$06 sta color1 lda #$0e sta color2 pla tax pla tay pla rti zaehl dta 0 ;------------------------------- vbi lda zaehl cmp #$5 bmi vbiout mva #0 zaehl lda c2 cmp #$0e beq set_c1 inc c2 inc c1 jmp vbiend set_c1 mva #0 zaehl lda #7 ;VBI ldx >vbi2 ;wird ldy <vbi2 ;jetzt jsr $e45c ;angeschaltet jmp $e462 ;VBI zuende und weiter mit System vbiout inc zaehl vbiend mwa #dli 512 jmp $e462 ;VBI zuende und weiter mit System ;----------- vbi2 mwa #dli2 512 lda zaehl cmp #120 bpl set_v3 inc zaehl jmp $e462 ;VBI zuende und weiter mit System set_v3 lda #7 ;VBI ldx >vbi3 ;wird ldy <vbi3 ;jetzt jsr $e45c ;angeschaltet jmp $e462 ;VBI zuende und weiter mit System ;------------ vbi3 mwa #dli3 512 jmp $e462 ;VBI zuende und weiter mit System ;------------------------------- org $a800 scr dta d'Some notes Rybags gave about Spectipede:' dta d'-'* dta d' The game should be able to run on a ' dta d' 32K machine so I',b(7),d'm targetting at that.' dta d'-'* dta d' It should be noted it',b(7),d's a conversion ' dta d' of a budget 2.99 game from Master- ' dta d' tronic for the Commodore Plus/4. It',b(7),d's ' dta d' got a bit of a bug in the game where ' dta d' sometimes you can run into an enemy ' dta d' without harm. Other times you get ' dta d' killed. Maybe it',b(7),d's the reason it was ' dta d' made into a budget title. ' dta d'-'* dta d' Be aware about a future VBXE version! ' run mainload ... the text editor is far better than this web code tool Quote Link to comment Share on other sites More sharing options...
Aces123 Posted September 14, 2014 Author Share Posted September 14, 2014 Wow thanks! It will take me a while to go through it all but I am sure I will learn a lot Quote Link to comment Share on other sites More sharing options...
pps Posted September 14, 2014 Share Posted September 14, 2014 But be aware, I did this in a few minutes back in 2011 and it is not really clean code The most of the first labels are not needed in the code, but I often use "snip and snap" and have the values in the code, so I can't forget to set something. Quote Link to comment Share on other sites More sharing options...
Aces123 Posted September 16, 2014 Author Share Posted September 16, 2014 Hello again ! If I wanted to run the original program in graphics 0, how would I do that? Quote Link to comment Share on other sites More sharing options...
pps Posted September 16, 2014 Share Posted September 16, 2014 Hello again ! If I wanted to run the original program in graphics 0, how would I do that? simply change the $47 into $42 in the dl.$46 for gfx 1 Quote Link to comment Share on other sites More sharing options...
Aces123 Posted September 16, 2014 Author Share Posted September 16, 2014 Thanks! It writes some garbage after Hello World (ppp I2p I-BP) How do I get rid of that? Quote Link to comment Share on other sites More sharing options...
Xuel Posted September 16, 2014 Share Posted September 16, 2014 Thanks! It writes some garbage after Hello World (ppp I2p I-BP) How do I get rid of that? Add 20 spaces after "WORLD!": text dta d' HELLO, ',d'WORLD!'*,d' ' Quote Link to comment Share on other sites More sharing options...
Xuel Posted September 16, 2014 Share Posted September 16, 2014 Or actually, only 16 since you have narrow screen mode enabled (32 characters across). Quote Link to comment Share on other sites More sharing options...
Aces123 Posted September 16, 2014 Author Share Posted September 16, 2014 Worked like a charm! Thanks 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.