SHARE
TWEET

hello-world.gb

luckytyphlosion Nov 22nd, 2015 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. INCLUDE "constants.asm"
  2.  
  3. SECTION "rst 00", ROM0 [$00]
  4. ClearVRAM:
  5. .clearVRAMLoop
  6.         ld [hld], a
  7.         bit 7, h
  8.         jr nz, .clearVRAMLoop
  9.         ret
  10. SECTION "rst 08", ROM0 [$08]
  11. HandleCommand:
  12.         and b
  13.         jr z, .done
  14.         cp b
  15.         ret z
  16.         add l
  17.         ld l, a
  18.         ld [hl], b
  19.         ret
  20. .done
  21.         xor a
  22.         ld [$98a0], a
  23.         ld hl,rLCDC
  24.         ld [hl], %11010011
  25.         jr @
  26.  
  27. SECTION "rst 20", ROM0 [$20]
  28.         push de
  29.         ld de, $20
  30.         add hl, de
  31.         pop de
  32.         ret
  33.  
  34. SECTION "Entry", ROM0 [$100]
  35.         db $18,$4e ; jr Start0150
  36.        
  37. SECTION "Header", ROM0 [$104]
  38.  
  39.         ; The header is generated by rgbfix.
  40.         ; The space here is allocated to prevent code from being overwritten.
  41.  
  42.         ds $150 - $104
  43.        
  44. Start0150:
  45.         di
  46.        
  47.         ld sp, $fffe
  48.         ; palettes
  49.         xor a
  50.         ld [rSCX], a
  51.         ld [rSCY], a
  52.         ld a, $e4
  53.         ld [rBGP], a
  54.        
  55. .waitForVBlank 
  56.         ld a, [rLY]
  57.         cp $90
  58.         jr nz, .waitForVBlank
  59.         xor a
  60.         ld c, a
  61.         ld [rLCDC], a
  62.         ld hl, $fe9f
  63. .clearOAMLoop
  64.         ld [hl], a
  65.         dec l
  66.         jr nz, .clearOAMLoop
  67.        
  68.         ld hl, $9fff
  69.         rst $00
  70.         ld hl, $800f
  71.         dec a
  72.         rst $00
  73.        
  74.         ld hl, $9800
  75.         ld de, HelloWorldOffsets
  76.         ld b, $f
  77.         ld [hl], b
  78.  
  79.         push hl
  80. .loadBytemapIntoVRAMLoop
  81.         ld a, [de]
  82.         ld c, a
  83.         swap a
  84.         rst $08
  85.         jr nz, .notNextLine
  86.         pop hl
  87.         rst $20
  88.         push hl
  89.         ld [hl], b
  90. .notNextLine
  91.         ld a, c
  92.         rst $08
  93.         inc de
  94.         jr nz, .loadBytemapIntoVRAMLoop
  95.         pop hl
  96.         rst $20
  97.         push hl
  98.         ld [hl], b
  99.         jr .loadBytemapIntoVRAMLoop
  100.  
  101. HelloWorldOffsets::
  102. ; commands:
  103. ; $01 - $0e = add offset to current pointer
  104. ; $00 = stop execution
  105. ; $0f = go to next line
  106.         dn $02,$02, $01,$02, $03,$03, $01,$01
  107.         dn $0f,$02, $02,$03, $03,$03, $02,$0f
  108.         dn $01,$01, $02,$01, $02,$03, $03,$02
  109.         dn $0f,$02, $02,$03, $03,$03, $02,$0f
  110.         dn $02,$02, $01,$02, $01,$02, $01,$02, $01,$01
  111.         dn $0f,$0f
  112.         dn $02,$02, $02,$01, $01,$02, $01,$03, $03,$01
  113.         dn $0f,$02, $02,$02, $02,$02, $02,$02, $03,$02
  114.         dn $0f,$02, $02,$02, $02,$02, $01,$03, $03,$02
  115.         dn $0f,$01, $01,$01, $03,$01, $01,$02, $02,$02, $01,$02, $01,$00
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top