newcoleco Posted August 9, 2010 Share Posted August 9, 2010 (edited) Yes, it's another famous "HELLO WORLD!" sample program. This time, "HELLO WORLD!" for the ColecoVision game system! If you like this program, please consider a reply to this message, or a vote for appreciation. I know that some programmers are willing to code something for the ColecoVision but don't get much information regarding how to do it in assembler, so I gave it a try and this is my version of HELLO WORLD for getting started with ColecoVision programming with ColecoVision BIOS calls. The following listing was done in order to play with it, to modify it and understand a few concepts, not only to be compiled and that's it. Put your name on the title screen, change the text to display and where to display it, etc. Filled with ColecoVision BIOS calls, this listing is a good example of what programmers in the 80s was doing in their commercial ColecoVision games. Have fun! ; COLECOVISION - HELLO WORLD! ; By Daniel Bienvenu, 2010 ; To be compiled with TNIASM ; BIOS (SOME) ENTRY POINTS CALC_OFFSET: equ $08c0 LOAD_ASCII: equ $1f7f FILL_VRAM: equ $1f82 MODE_1: equ $1f85 PUT_VRAM: equ $1fbe TURN_OFF_SOUND: equ $1fd6 WRITE_REGISTER: equ $1fd9 READ_REGISTER: equ $1fdc WRITE_VRAM: equ $1fdf ; VRAM DEFAULT TABLES VRAM_PATTERN: equ $0000 VRAM_NAME: equ $1800 VRAM_SPRATTR: equ $1B00 VRAM_COLOR: equ $2000 VRAM_SPRGEN: equ $3800 fname "hello2.rom" cpu Z80 ; switch to Z80 mode org $8000 ; HEADER db $aa,$55 ; use $55,$aa to avoid the default CV title screen dw 0,0,0,0 dw Start rst_8: reti nop rst_10: reti nop rst_18: reti nop rst_20: reti nop rst_28: reti nop rst_30: reti nop rst_38: reti nop jp Nmi db "HELLO WORLD!/PRINT ON SCREEN/2010" ; PROGRAM Start: im 1 ; CLEAR VIDEO MEMORY ld hl,$0000 ld de,$4000 xor a call FILL_VRAM ; INIT DEFAULT SCREEN GRAPHIC MODE 1 call MODE_1 ; NO SOUND call TURN_OFF_SOUND ; DEFAULT FONT TO VIDEO MEMORY call LOAD_ASCII ; COLOR WHITE ON BLACK BACKGROUND ld hl,VRAM_COLOR ; COLOR TABLE ld de,32 ld a,$f0 ; WHITE ON BLACK call FILL_VRAM ; PRINT "HELLO WORLD!" CENTERED AT THE TOP OF THE SCREEN ; FORMULA = (32 CHARS PER LINE - 12 CHARS TO OUTPUT) / 2 = 10 call Static_Offset ; or use Calculated_Offset call Write_HelloWorld ; or use Put_HelloWorld but make sure to not add VRAM NAME TABLE with the Offset ; 16KB VIDEO MEMORY, 16x16 NORMAL SPRITES, AND TURN ON SCREEN ld bc,$01c2 ; $01e2 ; = AND ENABLE NMI EXECUTION call WRITE_REGISTER TheEnd: jp TheEnd HelloWorld: db "HELLO WORLD!" Static_Offset: ld de,VRAM_NAME+10 ; VRAM NAME TABLE + OFFSET ret Calculated_Offset: ld d,0 ; LINE = 0 ld e,10 ; COLUMN = 10 call CALC_OFFSET ; OFFSET = 32 * D + E ld hl,VRAM_NAME add hl,de ex de,hl ret Write_HelloWorld: ld hl,HelloWorld ld bc,12 ; COUNT jp WRITE_VRAM Put_HelloWorld: ld a,2 ; ID#2 = VRAM NAME TABLE ld hl,HelloWorld ld iy,12 ; COUNT jp PUT_VRAM Nmi: ; RANDOM COLOR ON BLACK BACKGROUND ld hl,VRAM_COLOR ; COLOR TABLE ld de,32 ld a,r ; REFRESH MEMORY STATE USED AS A RANDOM VALUE and $f0 ; BLACK BACKGROUND call FILL_VRAM ; ABSOLUTELY NEEDED call READ_REGISTER retn * Bonus * The smallest ColecoVision program ever! NOTE : I'm not responsible if you see nothing because you modded your ColecoVision BIOS chip or if you're using an emulator that doesn't support so damn small ROM files. ; COLECOVISION - HELLO WORLD! ; By Daniel Bienvenu, 2010 ; To be compiled with TNIASM fname "hello.rom" cpu Z80 ; switch to Z80 mode org $8000 db $aa,$55 dw 0,0,0 Start: nop ret dw Start dw 0,0,0,0,0,0,0,0,0,0,0 retn db "HELLO WORLD!/ /2010" Edited August 9, 2010 by newcoleco 7 Quote Link to comment Share on other sites More sharing options...
Pixelboy Posted August 9, 2010 Share Posted August 9, 2010 Very cool! Thanks for the listings, I'll keep them in my archives, and I'll try them ASAP (which probably means early next year, as you know). Quote Link to comment Share on other sites More sharing options...
goldenegg Posted August 9, 2010 Share Posted August 9, 2010 Great post! That first chunk of code has to be the longest Hello World app I've ever seen Quote Link to comment Share on other sites More sharing options...
+retroclouds Posted August 9, 2010 Share Posted August 9, 2010 Thanks Daniel. Quote Link to comment Share on other sites More sharing options...
Pixelboy Posted August 9, 2010 Share Posted August 9, 2010 Great post! That first chunk of code has to be the longest Hello World app I've ever seen It would be much longer if he had defined his own text font! As it is, he's just using the default font from the BIOS. Quote Link to comment Share on other sites More sharing options...
youki Posted August 10, 2010 Share Posted August 10, 2010 Great post! That first chunk of code has to be the longest Hello World app I've ever seen It would be much longer if he had defined his own text font! As it is, he's just using the default font from the BIOS. It would be even much longer if he did'nt do BIOS Call. Thanks Daniel for the code. Quote Link to comment Share on other sites More sharing options...
newcoleco Posted August 19, 2010 Author Share Posted August 19, 2010 I've made videos on my Youtube channel about "Hello World!" for the ColecoVision. I hope this will bring even more programmers to get involved to ColecoVision scene. First - with ColecoVision title screen http://www.youtube.com/watch?v=eNr06jeDU-Y Second - With ColecoVision bios calls http://www.youtube.com/watch?v=arheSqY-L6A 3 Quote Link to comment Share on other sites More sharing options...
retroillucid Posted August 20, 2010 Share Posted August 20, 2010 I love this kind of video That is a very good learning guide to step onto Colecovision Homebrewing Thanks for sharing! +1 Would be nice to have more videos like those one Quote Link to comment Share on other sites More sharing options...
+retroclouds Posted August 20, 2010 Share Posted August 20, 2010 Thanks for sharing this Daniel. That's very cool Just wondering, is there a special reason why the tniASM cross assembler is used? Or will other Z80 assemblers work as well, e.g. the MSX sjam assembler ? Quote Link to comment Share on other sites More sharing options...
newcoleco Posted August 20, 2010 Author Share Posted August 20, 2010 Thanks for sharing this Daniel. That's very cool Just wondering, is there a special reason why the tniASM cross assembler is used? Or will other Z80 assemblers work as well, e.g. the MSX sjam assembler ? Short : It's the one I've decided to use. Long : You can use the compiler that fits better for you, every single assembler does have their particularities including special syntax and keywords that makes them not compatible, but when you know one well it's a good idea to use it. And I know better TNIASM than SJASM which I was not aware of before. And with TNIASM, I find it very cool to simply drag'n drop the file on the assembler icon and get a rom file ready to use; no need for a batch file to deal with options to type in the command line, it's simply done, bam! Norman Nithman used TASM (not turbo assembler but Table driven assembler) when he presented Tic Tac Toe and a few disassembled listings including Q*Bert to the Coleco fans in 1996. Why your question isn't about TASM instead of SJASM? TASM supports way more CPUs than SJASM and it was already used by a ColecoVision programmer. I know since now that SJASM exists and some MSX programmers use it. They manage to deal with CONText as an IDE and use a batch file to compile and run their projects. In my devkit also I've manage to use a compiler, Hi-Tech C at first and now SDCC, with my libraries by using a batch files creator I've called CCI (for Coleco Compiler Interface). TNIASM don't need a batch file. http://br.msx.org/forumtopic6173.html Quote Link to comment Share on other sites More sharing options...
newcoleco Posted August 21, 2010 Author Share Posted August 21, 2010 (edited) I love this kind of video ... Would be nice to have more videos like those one Just for you then... another video. Enjoy! http://www.youtube.com/watch?v=Ka6kRL9wWBg Note : Remember that a typical not working cartridge is rather a mess on screen, or a "TURN GAME OFF" message. But with this program, you can make the ColecoVision looks like it doesn't work at all. Edited August 21, 2010 by newcoleco 2 Quote Link to comment Share on other sites More sharing options...
retroillucid Posted August 21, 2010 Share Posted August 21, 2010 I love this kind of video ... Would be nice to have more videos like those one Just for you then... another video. Enjoy! http://www.youtube.com/watch?v=Ka6kRL9wWBg Note : Remember that a typical not working cartridge is rather a mess on screen, or a "TURN GAME OFF" message. But with this program, you can make the ColecoVision looks like it doesn't work at all. Thanks Daniel! I do really appreciate those little videos +1 Now, time to give this a try Quote Link to comment Share on other sites More sharing options...
l@k Posted August 26, 2010 Share Posted August 26, 2010 It's fabulous that you've put in so much effort in this and in all your works. I'll try it on my FPGA coleco soon. (like your other music pieces) lak. Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted May 9, 2011 Share Posted May 9, 2011 Sorry to bump this old of a thread, but... How do code this ASM to make a longer title, one on two or three lines? For example: "PRESENTS NINTENDO'S DONKEY KONG" (on two lines)? ~Ben Quote Link to comment Share on other sites More sharing options...
newcoleco Posted May 9, 2011 Author Share Posted May 9, 2011 Sorry to bump this old of a thread, but... How do code this ASM to make a longer title, one on two or three lines? For example: "PRESENTS NINTENDO'S DONKEY KONG" (on two lines)? ~Ben If you replace the "HELLO WORLD!/ /2010" by "DONKEY KONG/PRESENTS NINTENDO'S/1982" you get the effect you are looking for. Also, some other games try to write even more lines by adding spaces to artificialy add lines, but it's not normal usage. And there is no problem to bring back this kind of thread, it contains programming information that new and not so new to ColecoVision programming may enjoy reading. Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted May 9, 2011 Share Posted May 9, 2011 Sorry to bump this old of a thread, but... How do code this ASM to make a longer title, one on two or three lines? For example: "PRESENTS NINTENDO'S DONKEY KONG" (on two lines)? ~Ben If you replace the "HELLO WORLD!/ /2010" by "DONKEY KONG/PRESENTS NINTENDO'S/1982" you get the effect you are looking for. Also, some other games try to write even more lines by adding spaces to artificialy add lines, but it's not normal usage. And there is no problem to bring back this kind of thread, it contains programming information that new and not so new to ColecoVision programming may enjoy reading. Thank you, that worked! 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.