Jump to content





Programming Chip-8 ( RCA 1802 )

Posted by LS_Dracon, 03 September 2010 · 1,081 views

In my last entry I've posted one mockup, Pac-Man for RCA studio II.
At first a bizarre idea, today I did progress.

I've start to study about Chip-8 programming, and did progress!

In less than an hour I've written an hello word code.

Chip-8 is a language that come from Cosmac VIP computer released by RCA in 1977.
It's basically a RCA studio II computer. There are many emulator for chip-8, even for gamming platforms such gameboy and vectrex. Today there is super and mega chip-8 variations with more resolution and in color.

The video display 64x32 monocrome pixels of resolution and single sound channel.

I find quite easy and fun to code, at least in the first hour.
Don't know why I'm codding for it. Mainly because I have tons of projects to finish.
I think because the challenge.

My next step is a playable pong.

Edit : Added the image of the moving sprite.

Attached Thumbnails

  • Attached Image
  • Attached Image





Today I did a sprite moving.
I think I'll explode by happiness....
Nope.

Here's the code, for sake the curiosity

; ---- Sprite movement ---
OPTION BINARY
ALIGN OFF

;Registers I'm using
; V0 Temp
; V1 player X
; V2 player Y

; keys:
; #2 = up
; #4 = left
; #5 = space
; #6 = right
; #8 = down
; #A = Ctrl
; #B = shift
; #C = Z
; #F = Space

;-----------------------------
Gamestart

cls ;CleanScreen

ld v1,32 ;Load X to initial position 32 on the screen (half of the 64)
ld v2,16 ;Load Y to position 16 (half of the 32 Y resolution)
;-----------------------------
GameLoop

ld v0,#2 ;Load Up to V0 register
skp v0 ;Check if pressed (v0 != 0)
jp CheckDown ;No, jump to "CheckDown"
add v2,#FF ;Yes, add -1 to Y (V2) (#FF = -1)

CheckDown
ld v0,#8 ;Load Down
skp v0 ;Pressed?
jp CheckRight ;No, jump
add v2,1 ;yes, +1 to Y

CheckRight
ld v0,#6
skp v0
jp CheckLeft
add v1,1

CheckLeft
ld v0,#4
skp v0
jp Reset
add v1,#FF

Reset
ld v0,#C
skp v0
jp DrawingCode
jp Gamestart

;-----------------------------
DrawingCode

cls ;Clear Screen

ld I,Sprite0 ;Point I (indexer) to Sprite0 Table
drw v1,v2,9 ;Draw Sprite0 using v1 and v2 as X and Y. 9 is the height of the sprite table

;TimeDelay

ld v0,1 ;Load 5 to v0
ld dt,v0 ;Set V0 as timmer (DT)

WaitDelay
ld v0,dt ;Decrement V0 using DT
se v0,0 ;If 0, go to jp GameLoop
jp WaitDelay ;If Non-zero, repeat

jp Gameloop ;End of the code. Jump to GameLoop and repeat process.

;------------------------------

Sprite0 ;Sprite Data
DB $...11...
DB $..1111..
DB $...11...
DB $.111111.
DB $1..11..1
DB $1..11..1
DB $..1..1..
DB $..1..1..
DB $.11..11.



There are 16 registers, V0 to V9 and VA to VF. They are general pourpose less VF wich is set when colision happens, also VF hang the carry.Chip8 support subroutine by 16 levels. There is one indexer named I.Skp is a short branch, skip 2 bytes (next instruction) if Vx is non-zero.Well, see ya.
  • Report

May 2019

S M T W T F S
   1234
567891011
12131415161718
19202122232425
26 2728293031