d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Z80 Assembly (coleco - Tasm)
Add Reply New Topic New Poll
Member
Posts: 6,114
Joined: Jul 11 2007
Gold: 35.78
Nov 27 2022 11:15am
ts been 40 years and I have always wanted to learn how to make games for the coleco and other systems and now is my chance :)
if anyone is interested in trying to make a comunity built game for coleco in assembly language please contact me. I have been trying to learn from 8-bit Mill's code and have made some interesting discoveries looking over his code.

Extract tasm to the folder you have your source file in
assemble using:
tasm filename.z80 -80 -b
rename using:
ren filename.obj filename.rom

dosbox download:
https://www.dosbox.com/download.php?main=1

tasm download:
https://www.ticalc.org/pub/dos/asm/

MSX/Coleco Sprite & Tile Set Editor:
https://www.electricadventures.net/Pages/Category/24


Ill be demonstrating how to code in z80 assembly for colecovision and adam.
starting from baby steps as im just starting to learn myself
Member
Posts: 6,114
Joined: Jul 11 2007
Gold: 35.78
Nov 27 2022 11:48am

Thanks to https://8bitmilligames.com/ for helping me with this code!
Code
;cartridge header and title example

.org $8000


TitleControl .dw 055AAh

.dw 0,0,0,0, start
.dw 0,0,0,0,0,0,0,0,0,0,0

retn
.text "YOUR NAME/HELLO WORLD!/2022"
start:
jp $0000
.end

title and skill select screen with hello world instead

Code
.org $8000


TitleControl .dw 055AAh

.dw 0,0,0,0, start
.dw 0,0,0,0,0,0,0,0,0,0,0

retn
.text "YOUR NAME/HELLO WORLD!/2022"
start:
call $1f85 ; cv bios : mode_1
call $1fd6 ; cv bios : turn off sound

;clear video ram
ld a,0
ld hl,0
ld de,$4000
call $1f82 ; cv bios : fill_vram

;color white (f) on blue (4)
ld a,$f4
ld hl,$2000
ld de,32
call $1f82 ; cv bios : fill_vram
call $1f7f ; cv bios : load_ascii

; print "helloworld!"
ld de,$1800
ld hl,helloworld
ld bc,12
call $1fdf ; cv bios :write_vram
ld de,$1820
ld hl,nextline
ld bc,28
call $1fdf ; cv bios :write_vram
ld de,$1840
ld hl,helloworld
ld bc,12
call $1fdf ; cv bios :write_vram

; screen on
ld bc,$01c2
call $1fd9 ; cv bios :write_register

; infinite loop
end:
jp end
.end

helloworld:
.db "HELLO WORLD!"
nextline:
.db "this is the hello world demo"


This post was edited by implite on Nov 27 2022 12:15pm
Member
Posts: 6,114
Joined: Jul 11 2007
Gold: 35.78
Nov 27 2022 12:25pm
music added:
Thanks to (Newcoleco)
still not sure if this is the correct method to do this however it works so im adding it :)
Code
;COPS (Bad Boys) demo, ColecoVision version music by Daniel Bienvenu, 2010.
.org $8000

.dw $55AA,0,0,0,0,start
.dw 0,0,0,0,0,0,0,0,0,0

ret
jp nmi
.text "BAD BOYS/COPS!(DEMO)/2022"

nmi:
push hl
ld hl,$72FF
inc (hl)
pop hl
;;; UPDATE SOUND
call $1f61 ; play sounds
call $1ff4 ; update snd_addr with snd_areas
;;; READ VIDEO STATUS
in a,($bf)
retn


start:
;call $1f85 ; cv bios : mode_1
;call $1fd6 ; cv bios : turn off sound

;clear video ram
ld a,0
ld hl,0
ld de,$4000
call $1f82 ; cv bios : fill_vram

;color white (f) on blue (4)
ld a,$f4
ld hl,$2000
ld de,32
call $1f82 ; cv bios : fill_vram
call $1f7f ; cv bios : load_ascii

; print "helloworld!"
ld de,$1800
ld hl,helloworld
ld bc,14
call $1fdf ; cv bios :write_vram
ld de,$1820
ld hl,nextline
ld bc,27
call $1fdf ; cv bios :write_vram
ld de,$1840
ld hl,helloworld
ld bc,14
call $1fdf ; cv bios :write_vram

ld hl, snd_table
ld b,4
call $1fee

ld a,1
call playsound
ld a,2
call playsound
ld a,3
call playsound
ld a,4
call playsound

; screen on
ld bc,$01c2
ld bc,$01e2
call $1fd9 ; cv bios :write_register

helloworld:
.db "COPS! Bad Boys"
nextline:
.db "This is the Bad Boys (demo)"

; infinite loop
end:
jp end
.end

playsound:
ld b,a
jp $1ff1

snd_table:
.dw ch0,$702b ; = 1
.dw ch1,$702b+10 ; = 1
.dw ch2,$702b+20 ; = 1
.dw ch3,$702b+30 ; = 1


; DRUM + BASS (effect)

ch0:

.db $02,$53,$0a,$1a,$21

.db $02,$56,$0a,$25,$12

.db $2a

.db $02,$53,$0a,$1a,$21

.db $02,$55,$14,$1a,$21

.db $02,$53,$14,$1a,$32

.db $18



; BASS (frequencies)

ch3:

.db $c0,$44,$f0,$28

.db $c0,$5a,$f0,$28

.db $c0,$33,$f0,$14

.db $c0,$b5,$f0,$0a

.db $c0,$5a,$f0,$0a

.db $c0,$3c,$f0,$28

.db $d8



; Kinda melody support / extra percussion

ch1:

.db $42,$fc,$61,$0a,$18,$21

.db $6a

.db $42,$fc,$61,$0a,$18,$21

.db $42,$fc,$61,$0a,$18,$21

.db $74

.db $42,$fc,$61,$14,$18,$21

.db $42,$fc,$61,$0a,$18,$21

.db $6a

.db $42,$fc,$61,$0a,$18,$21

.db $42,$fc,$61,$0a,$18,$21

.db $74

.db $42,$fc,$61,$14,$18,$21

.db $42,$81,$62,$0a,$18,$21

.db $6a

.db $42,$53,$61,$0a,$18,$21

.db $42,$a7,$62,$0a,$18,$21

.db $74

.db $42,$53,$61,$14,$18,$21

.db $42,$fc,$61,$0a,$18,$21

.db $6a

.db $42,$fc,$61,$0a,$18,$21

.db $42,$fc,$61,$0a,$18,$21

.db $74

.db $42,$fc,$61,$14,$18,$21

.db $58



; Melody (voice)

ch2:

.db $82,$53,$41,$14,$1a,$32

.db $82,$fe,$40,$14,$1a,$32

.db $82,$53,$41,$14,$1a,$32

.db $b4

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$d6,$40,$14,$1a,$32

.db $b4

.db $82,$d6,$40,$0a,$1a,$22

.db $82,$d6,$40,$0a,$1a,$22

.db $82,$d6,$40,$0a,$1a,$22

.db $82,$d6,$40,$0a,$1a,$22

.db $82,$d6,$40,$14,$1a,$32

.db $82,$d6,$40,$0a,$1a,$22

.db $82,$be,$40,$0a,$1a,$22

.db $82,$fe,$40,$14,$1a,$32

.db $82,$fe,$40,$14,$1a,$32

.db $82,$fe,$40,$28,$1a,$43

.db $82,$53,$41,$14,$1a,$32

.db $82,$fe,$40,$14,$1a,$32

.db $82,$53,$41,$14,$1a,$32

.db $b4

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$d6,$40,$14,$1a,$32

.db $b4

.db $82,$d6,$40,$0a,$1a,$22

.db $82,$d6,$40,$0a,$1a,$22

.db $82,$d6,$40,$0a,$1a,$22

.db $82,$d6,$40,$0a,$1a,$22

.db $82,$d6,$40,$14,$1a,$32

.db $82,$8f,$40,$0a,$1a,$22

.db $82,$8f,$40,$0a,$1a,$22

.db $82,$7f,$40,$14,$1a,$32

.db $82,$7f,$40,$14,$1a,$32

.db $82,$7f,$40,$1e,$1a,$43

.db $82,$aa,$40,$0a,$1a,$22

.db $82,$aa,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$14,$1a,$32

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$14,$1a,$32

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$d6,$40,$1e,$1a,$43

.db $b4,$b4

.db $82,$be,$40,$0a,$1a,$22

.db $82,$aa,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$14,$1a,$32

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$be,$40,$14,$1a,$32

.db $82,$d6,$40,$28,$1a,$43

.db $82,$be,$40,$1e,$1a,$43

.db $82,$be,$40,$0a,$1a,$22

.db $82,$aa,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$14,$1a,$32

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$14,$1a,$32

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$d6,$40,$1e,$1a,$43

.db $b4,$b4

.db $82,$be,$40,$0a,$1a,$22

.db $82,$aa,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$14,$1a,$32

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$fe,$40,$0a,$1a,$22

.db $82,$be,$40,$14,$1a,$32

.db $82,$d6,$40,$14,$1a,$32

.db $82,$aa,$40,$14,$1a,$32

.db $82,$aa,$40,$28,$1a,$43

.db $98


This post was edited by implite on Nov 27 2022 12:35pm
Member
Posts: 6,114
Joined: Jul 11 2007
Gold: 35.78
Dec 25 2022 11:36am
;not so minimal coleco snow demo
;makes three stars or snowflakes
.org $8000
NBR_SPRITES: .equ 3
.dw $55AA,SprAttrib,$7000,0,0,GameStart
.dw 0,0,0,0,0,0,0,0,0,0,0
retn
.text "IMPLITE/SNOWFLAKE (DEMO)/2022"
GameStart:
call $1f85 ; MODE_1
call $1fd6 ; Turn_Off_Sound
ld hl,0 ; clear VRAM
ld de,$4000
xor a
call $1f82 ; fill_vram
ld de,$3800 ;load sprite pattern
ld hl,star
ld bc,32
call $1fdf ; write_vram
ld a,NBR_SPRITES ; init sprites order
call $1fc1 ; init_spr_order
ld a,NBR_SPRITES ; Disply sprites
call $1fc4 ; wr_spr_nm_tbl
ld a,$d0
out ($be),a
ld bc,$01c2 ;turn on disply
call $1fd9 ; write_Register
TheEnd:
jp TheEnd
.end
SprAttrib:
.db 60,50,0,15 ; Y=88 x=120 pattern#0, color=10
.db 8,20,0,15 ; Y=88 x=120 pattern#0, color=10
.db 88,120,0,15 ; Y=88 x=120 pattern#0, color=10
star:
.db 00000000b
.db 00001000b
.db 00001100b
.db 00001110b
.db 00001111b
.db 11111111b
.db 00111111b
.db 00011111b
.db 00001111b
.db 00011111b
.db 00111111b
.db 11111111b
.db 00001111b
.db 00001110b
.db 00001100b
.db 00001000b

.db 00000000b
.db 00010000b
.db 00110000b
.db 01110000b
.db 11110000b
.db 11111111b
.db 11111100b
.db 11111000b
.db 11110000b
.db 11111000b
.db 11111100b
.db 11111111b
.db 11110000b
.db 01110000b
.db 00110000b
.db 00010000b
;colors
;TRANS .equ 0
;BLACK * .equ 1
;MGREEN * .equ 2
;LGREEN * .equ 3
;DBLUE .equ 4
;LBLUE .equ 5
;DRED * .equ 6
;CYAN * .equ 7
;MRED * .equ 8
;LRED * .equ 9
;DYELLOW * .equ 10
;LYELLOW * .equ 11
;DGREEN * .equ 12
;MAGENTA * .equ 13
;GRAY * .equ 14
;WHITE * .equ 15
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll