Nintendo DMG-01 Manual - Page 135

Emulator Notes

Page 135 highlights

Game BoyTM CPU Manual 5.1. Emulator Notes Write1: ldh a,[$41] ;read $ff41 and 2 jr nz,Write1 ld [hl],b ei ;turn on interrupts ret There should not be many instructions between the "jr nz" and write to memory "ld [hl],b". A worst case of 64 CPU clock cycles are available to access main video memory (not OAM!) following the "jr nz" command. The "di" and "ei" commands above are only required if you are using Serial, Timer, or Hi-2-Lo interrupts. 5. The LCD display is on at reset (bit 7 of $ff40 set to bit 7 of $ff40 set to 1). Before the LCD display can be turned off you must wait for V-Blank. One popular way of doing this is the following: ; Turn off LCD display LCDOff: ldh a,[$44h] ; $ff44=LCDC Y-Pos cp $90 ; $90 and bigger = in VBL jr nz,LCDOff ; Loop until = $90 xor a ldh [$41],a ; Turn off LCD display ret Note you should disable interrupts, if they are enabled, before executing the above code or else the test of $ff44 could prove invalid. Turning the LCD display on can be done at any time. by DP Page 135

  • 1
  • 2
  • 3
  • 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
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139

Game Boy
TM
CPU Manual
5.1. Emulator Notes
Write1:
ldh a,[$41]
;read $ff41
and 2
jr nz,Write1
ld [hl],b
ei
;turn on interrupts
ret
There should not be many instructions between the "jr
nz" and write to memory "ld [hl],b". A worst case of
64 CPU clock cycles are available to access main
video memory (not OAM!) following the "jr nz"
command.
The "di" and "ei" commands above are only required
if you are using Serial, Timer, or Hi-2-Lo
interrupts.
5. The LCD display is on at reset (bit 7 of $ff40 set to
bit 7 of $ff40 set to 1). Before the LCD display can
be turned off you must wait for V-Blank. One popular
way of doing this is the following:
; Turn off LCD display
LCDOff:
ldh a,[$44h]
; $ff44=LCDC Y-Pos
cp $90
; $90 and bigger = in VBL
jr nz,LCDOff
; Loop until = $90
xor a
ldh [$41],a
; Turn off LCD display
ret
Note you should disable interrupts, if they are
enabled, before executing the above code or else the
test of $ff44 could prove invalid.
Turning the LCD display on can be done at any time.
by DP
Page 135