Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2016-01-05 04:49:34

Glad
Member
From: France
Registered: 2015-03-04
Posts: 28
Website

ASM problem (level noob)

So I'm starting ASM for a new project and I just wanted to display a full GB screen.
This is my first time trying assembly so forgive me if there is a lot of mistakes.
The thing is, when I try to compile my program with RGBDS, it give me an error message at line 1 which is ".org $0000"...

I don't understand what's going on so if you guys can help me, it will be awesome !

I let you my code below

-----------------------------------------------------------------------------------------------

.org $0000
.org $0040              ; VBlank IRQ
reti                   ; do nothing
.org $0048              ; LCDC Status IRQ
reti                   ; Do nothing
.org $0050              ; Timer Owerflow
reti                   ; Do nothing
.org $0058              ; Serial Transfear Completion
reti                   ; Do nothing
.org $0060              ; Hmm, this is a wierd on
                        ; Im not sure how this one works
                        ; Transition from high to low
                        ; of pin p10-p13
                        ; I think Its a hardware thing
reti                   ; Do nothing
                        ; Irqs done..

.org $0100
nop
jp start

.ORG $0104
;Logo Nintendo, obligatoire
.db $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C
.db $00,$0D,$00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6
.db $DD,$DD,$D9,$99,$BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC
.db $99,$9F,$BB,$B9,$33,$3E

.db "WUTR_TEST  "       ; Cart name   16bytes
.db $00,$00,$00         ; Not used
.db $00                 ; Cart type   ROM Only
.db $00                 ; ROM Size    32k
.db $00                 ; RAM Size     0k
.db $cf,$08             ; Maker ID Matthew Johnson
.db $01                 ; Version     =1
.db $DA                 ; Complement check (Important)
.db $ff,$ff             ; Cheksum, fix this if you are going to
                        ; run this in VGB, or simpy use the -NOCRC
                        ; switch in the VGB-DOS command line.

;************************************************
;               Code start here                 *
;************************************************

.org $150

start:
                        ; This is addr $0150
ld     sp,$fff4        ; Put the stack where the GB wants it
ld     a,%00000001     ; No IRQs but VBlank   <<<vblank interrupt on
ldh    ($ff),a
sub    a               ; Misc standard init things..
ldh    ($41),a         ; LCDC Status

call    waitvbl        ; Must be in VBL before turning the screen off
ld     a,%00000000     ; LCD Controller = Off (No picture on screen)
                        ; WindowBank = $9800 (Not used)
                        ; Window = OFF
                        ; BG Chr = $8000
                        ; BG Bank= $9800
                        ; Sprites= 8x8 (Size Assembly, 1=8x16)
                        ; Sprites= Off (Sprites on or off)
                        ; BG     = Off
ldh    ($40),a


;****************************************
;               Functions               *
;****************************************

;****************************************
;                 setup                 *
;****************************************

setup:           
                 

ld    bc,chrset
call   mchar           ; Moving background tiles
ld    bc,chrmap
call   map             ; Moving background map
call  nor_col          ; Setting up palette
call    waitvbl        ; Must be in VBL before turning the screen off
ld     a,%10001001     ; LCD Controller = On
                        ; WindowBank = $9800 (Not used)
                        ; Window = OFF
                        ; BG Chr = $8000
                        ; BG Bank= $9800
                        ; Sprites= 8x8 (Size Assembly, 0=8x8)
                        ; Sprites= Off
                        ; BG     = On
ldh    ($40),a

;****************************************
;        Wait for VBlank                *
;****************************************

waitvbl:

.db     $f0,$40        ; ld a,($40)
add    a,a
ret    nc

;****************************************
;        Moving background tiles        *
;****************************************

mchar:

ld     hl,$8000
ld     d,$00           ; move 256 bytes
ld     e,$12           ; x2=512. Increase this value
                        ; to copy more of the character set.
mchar_loop:

ldh     a,($41)        ; There are only certain times you
and     2              ; can write out scrn/tile.  This
jr nz,mchar_loop       ; loop waits for those times.
ld     a,(bc)
ld     (hli),a
inc    bc
dec    d
jp     nz,mchar_loop
dec    e
jp     nz,mchar_loop
ret

;****************************************
;        Moving background map          *
;****************************************

map:
ld     hl,$9800
ld     d,$00
ld     e,$04           ; 256*4=1024=32x32=One whole GB Screen

map_loop:

ldh     a,($41)        ; There are only certain times you
and     2              ; can write out scrn/tile.  This
jr         nz,map_loop ; loop waits for those times.
ld     a,(bc)
ld     (hli),a
inc    bc
dec    d
jp     nz,map_loop
dec    e
jp     nz,map_loop
ret

;****************************************
;           Setting up palette          *
;****************************************

nor_col:
                        ; Sets the colors to normal palette
ld     a,%11100100     ; grey 3=11 (Black)
                        ; grey 2=10 (Dark grey)
                        ; grey 1=01 (Ligth grey)
                        ; grey 0=00 (Transparent)
ldh    ($47),a

ret


chrset:
#include "bkg_tiles.bin"      ;my tiles



chrmap:
#include "bkg_map.inc"        ;my map


.block $008000-$
.end start


Another boring artist.

Current software project --> Walking under the rain (GB)
Current hardware project --> GlitchBoy

Offline

 

#2 2016-01-05 07:19:03

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: ASM problem (level noob)

I'm pretty sure that's WLA assembly, not RGBDS. https://github.com/vhelin/wla-dx

Offline

 

#3 2016-01-05 10:10:08

l0k1
Member
Registered: 2014-10-23
Posts: 44

Re: ASM problem (level noob)

Yeah agreed. Definitely WLA assembly, not RGBDS.

Edit: to convert to RGBDS, change .db to db, and use SECTION headings instead of .org.

EDIT2: Here's the header info for a project I was working on, so you can see how I did it, etc. I copied the template from somewhere (ASMSchool, I think?), feel free to copy or whatever. Project at https://github.com/l0k1/superhappyfunbubbletime.

Code:

;* SUPER HAPPY FUN BUBBLE TIME
;*
;* Includes
;constants:
INCLUDE  "globals.asm"

;* cartridge header

   SECTION  "Org $00",HOME[$00]
RST_00:  
   jp $100

   SECTION  "Org $08",HOME[$08]
RST_08:  
   jp $100

   SECTION  "Org $10",HOME[$10]
RST_10:
   jp $100

   SECTION  "Org $18",HOME[$18]
RST_18:
   jp $100

   SECTION  "Org $20",HOME[$20]
RST_20:
   jp $100

   SECTION  "Org $28",HOME[$28]
RST_28:
   jp $100

   SECTION  "Org $30",HOME[$30]
RST_30:
   jp $100

   SECTION  "Org $38",HOME[$38]
RST_38:
   jp $100

   SECTION  "V-Blank IRQ Vector",HOME[$40]
VBL_VECT:
   call V_Blank_Int
   reti
   
   SECTION  "LCD IRQ Vector",HOME[$48]
LCD_VECT:
   reti

   SECTION  "Timer IRQ Vector",HOME[$50]
TIMER_VECT:
   call Timer_Update
   reti

   SECTION  "Serial IRQ Vector",HOME[$58]
SERIAL_VECT:
   reti

   SECTION  "Joypad IRQ Vector",HOME[$60]
JOYPAD_VECT:
   call Controller                        ;in seperate file named "controller.asm"
   reti
   
   SECTION  "Start",HOME[$100]
   nop
   jp Main

   ; $0104-$0133 (Nintendo logo - do _not_ modify the logo data here or the GB will not run the program)
   DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
   DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
   DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E

   ; $0134-$013E (Game title - up to 11 upper case ASCII characters; pad with $00)
   DB "SHFBT",0,0,0,0,0,0
      ;0123456789A

   ; $013F-$0142 (Product code - 4 ASCII characters, assigned by Nintendo, just leave blank)
   DB "    "
      ;0123

   ; $0143 (Color GameBoy compatibility code)
   DB $00   ; $00 - DMG 
         ; $80 - DMG/GBC
         ; $C0 - GBC Only cartridge

   ; $0144 (High-nibble of license code - normally $00 if $014B != $33)
   DB $0F

   ; $0145 (Low-nibble of license code - normally $00 if $014B != $33)
   DB $0F

   ; $0146 (GameBoy/Super GameBoy indicator)
   DB $00   ; $00 - GameBoy

   ; $0147 (Cartridge type - all Color GameBoy cartridges are at least $19)
   DB $1B   ; $1B - ROM + MBC5 + RAM + BATT

   ; $0148 (ROM size)
   DB $08   ; $08 - 64MBit = 8MByte = 512 Banks

   ; $0149 (RAM size)
   DB $04   ; $04 - 1 Mbit = 128kB = 16 Banks

   ; $014A (Destination code)
   DB $01   ; $01 - All others
         ; $00 - Japan

   ; $014B (Licensee code - this _must_ be $33)
   DB $33   ; $33 - Check $0144/$0145 for Licensee code.

   ; $014C (Mask ROM version - handled by RGBFIX)
   DB $00

   ; $014D (Complement check - handled by RGBFIX)
   DB $00

   ; $014E-$014F (Cartridge checksum - handled by RGBFIX)
   DW $00

Last edited by l0k1 (2016-01-05 10:44:00)

Offline

 

#4 2016-01-05 15:18:42

Glad
Member
From: France
Registered: 2015-03-04
Posts: 28
Website

Re: ASM problem (level noob)

Thanks guys  ! You're awesome !


Another boring artist.

Current software project --> Walking under the rain (GB)
Current hardware project --> GlitchBoy

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson