Class: Rubygb::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygb/template/template.rb

Class Method Summary collapse

Class Method Details

.basic(name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/rubygb/template/template.rb', line 4

def self.basic name
%(; #{name}.s
;
; TODO: summary

INCLUDE "lib/gbhw.inc" ; gameboy hardware definitions
INCLUDE "lib/ibmpx1.inc" ; ibm ascii font macros


; interrupts
SECTION "Vblank",HOME[$0040]
  reti
SECTION "LCDC",HOME[$0048]
  reti
SECTION "Timer_Overflow",HOME[$0050]
  reti
SECTION "Serial",HOME[$0058]
  reti
SECTION "p1thru4",HOME[$0060]
  reti

; jump to start of user code at `begin`

SECTION "start",HOME[$0100]
nop
jp begin

; rom header - no memory bank controller, 32k rom, 0; ram
  ROM_HEADER ROM_NOMBC, ROM_SIZE_32KBYTE, RAM_SIZE_0KBYTE


INCLUDE "lib/memory.inc"; memory copying macros

TileData:
  chr_IBMPC1 1,8 ; LOAD ENTIRE CHARACTER SET

; initialization
begin:
  nop
  di
  ld sp, $ffff  ; set the stack pointer to highest mem location + 1
init:
  ld a, %11100100  ; Window palette colors, from darkest to lightest
  ld [rBGP], a  ; CLEAR THE SCREEN

  ld a,0   ; SET SCREEN TO TO UPPER RIGHT HAND CORNER
  ld [rSCX], a
  ld [rSCY], a
  call StopLCD  ; YOU CAN NOT LOAD $8000 WITH LCD ON
  ld hl, TileData
  ld de, _VRAM  ; $8000
  ld bc, 8*256   ; the ASCII character set: 256 characters, each with 8 bytes of display data
  call mem_CopyMono ; load tile data
  ld a, LCDCF_ON|LCDCF_BG8000|LCDCF_BG9800|LCDCF_BGON|LCDCF_OBJ16|LCDCF_OBJOFF
  ld [rLCDC], a
  ld a, 32  ; ASCII FOR BLANK SPACE
  ld hl, _SCRN0
  ld bc, SCRN_VX_B * SCRN_VY_B
  call mem_SetVRAM

; main
  ld hl,Title
  ld de, _SCRN0+3+(SCRN_VY_B*7) ;
  ld bc, TitleEnd-Title
  call mem_CopyVRAM

wait:
  halt
  nop
  jr  wait

Title:
  DB  "#{name} + rubygb!"
TitleEnd:

StopLCD:
  ld a,[rLCDC]
  rlca
  ret nc

.wait:
  ld a,[rLY]
  cp 145
  jr nz,.wait


  ld a,[rLCDC]
  res 7,a
  ld [rLCDC],a

  ret
)

end