Gameboy boot Rom assembly code and comments

Source: Internet
Author: User

After the Gameboy power is turned on, a 256-byte program will be loaded to the 0 position of the memory and run. This program is left and right. Check the card with a verification code and display and scroll the logo, the following code and comments are used to play the prompts:

LD sp, $ fffe; $0000 set the stack pointer <br/> xor a; $0003 reset the $8000-$ 9fff part (Display memory) <br/> ld hl, $ 9fff; $0004 <br/> addr_0007: <br/> LD (HL-), A; $0007 <br/> bit 7, H; $0008 <br/> Jr NZ, addr_0007; $ 000a <br/> ld hl, $ ff26; $ 000c set audio <br/> ld c, $11; $ 000f <br/> ld a, $80; $0011 <br/> LD (HL-), A; $0013 <br/> LD ($ ff00 + C), a; $0014 <br/> Inc C; $0015 <br/> ld a, $ F3; $0016 <br/> LD ($ ff00 + C), a; $0018 <br/> LD (HL -), a; $0019 <br/> ld a, $77; $ 001a <br/> LD (HL), A; $ 001c <br/> ld a, $ FC; $ 001d set the background palette <br/> LD ($ ff00 + $47), A; $ 001f <br/> LD de, $0104; $0021 convert the logo from the cassette and load it into the video memory <br/> ld hl, $8010; $0024 <br/> addr_0027: <br/> lD, (DE); $0027 <br/> call $0095; $0028 <br/> call $0096; $ 002b <br/> Inc de; $ 002e <br/> ld a, E; $ 002f <br/> CP $34; $0030 <br/> Jr NZ, addr_0027; $0032 <br/> LD de, $00d8; $0034 load the attached 8 bytes to the video memory <br/> ld B, $08; $0037 <br/> addr_0039: <br/> ld a, (de); $0039 <br/> Inc de; $ 003a <br/> LD (HL +),; $ 003b <br/> Inc HL; $ 003c <br/> dec B; $ 003d <br/> Jr NZ, addr_0039; $ 003e <br/> lD, $19; $0040 set the background tilemap <br/> LD ($9910), A; $0042 <br/> ld hl, $ 992f; $0045 <br/> addr_0048: <br/> ld c, $ 0C; $0048 <br/> addr_004a: <br/> dec A; $ 004a <br/> Jr Z, addr_0055; $ 004b <br/> LD (HL-), A; $ 004d <br/> dec c; $ 004e <br/> Jr NZ, addr_004a; $ 004f <br/> ld l, $ 0f; $0051 <br/> Jr addr_0048; $0053 <br/>; === scroll the logo on the screen and play a logo sound ===< br/> addr_0055: <br/> ld h, A; $0055 load the scroll count, H = 0 <br/> ld a, $64; $0056 <br/> ld d, a; $0058 set the cyclic count, D = $64 <br/> LD ($ ff00 + $42), a; $0059 set the horizontal scroll register <br/> ld a, $91; $ 005b <br/> LD ($ ff00 + $40), a; $ 005d enable LCD, display background <br/> Inc B; $ 005f <br/> addr_0060: <br/> ld e, $02; $0060 <br/> addr_0062: <br/> ld c, $ 0C; $0062 <br/> addr_0064: <br/> ld a, ($ ff00 + $44); $0064 waiting for screen seek <br/> CP $90; $0066 <br/> Jr NZ, addr_0064; $0068 <br/> dec c; $ 006a <br/> Jr NZ, addr_0064; $ 006b <br/> dec E; $ 006d <br/> Jr NZ, addr_0062; $ 006e <br/> ld c, $13; $0070 <br/> Inc h; $0072 auto-increment rolling count <br/> ld a, h; $0073 <br/> ld e, $83; $0074 <br/> CP $62; $0076 playback sound #1 after 62 times <br/> Jr Z, addr_0080; $0078 <br/> ld e, $ C1; $ 007a <br/> CP $64; $ 007c <br/> Jr NZ, addr_0086; $ 007e: After 64 times of counting, the playing sound # <br/> addr_0080: <br/> ld a, E; $0080 play sound <br/> LD ($ ff00 + C), a; $0081 <br/> Inc C; $0082 <br/> ld a, $87; $0083 <br/> LD ($ ff00 + C), a; $0085 <br/> addr_0086: <br/> ld a, ($ ff00 + $42 ); $0086 <br/> sub B; $0088 <br/> LD ($ ff00 + $42),; $0089 if B = 1, scroll up <br/> dec D; $ 008b <br/> Jr NZ, addr_0060; $ 008c <br/> dec B; $ 008e auto-minus B <br/> Jr NZ, addr_00e0; $ 008f... jump to "Nintendo logo check" <br/> ld d, $20; $0091 use a rolling loop to suspend <br/> Jr addr_0060; $0093 <br/>; ==== image part ===< br/> ld c, A; $0095 convert image data and store it in the video memory <br/> ld B, $04; $0096 <br/> addr_0098: <br/> push BC; $0098 <br/> rl c; $0099 <br/> RLA; $ 009b <br/> pop BC; $ 009c <br/> rl c; $ 009d <br/> RLA; $ 009f <br/> dec B; $00a0 <br/> Jr NZ, addr_0098; $00a1 <br/> LD (HL +), A; $00a3 <br/> Inc HL; $00a4 <br/> LD (HL +), A; $00a5 <br/> Inc HL; $00a6 <br/> ret; $00a7 <br/> addr_00a8: <br/>; Nintendo logo <br/>. DB $ ce, $ ed, $66, $66, $ CC, $ 0d, $00, $ 0b, $03, $73, $00, $83, $00, $ 0C, $00, $ 0d <br/>. DB $00, $08, $11, $ 1f, $88, $89, $00, $ 0e, $ DC, $ CC, $ 6e, $ E6, $ DD, $ DD, $ D9, $99 <br/>. DB $ BB, $ BB, $67, $63, $ 6e, $ 0e, $ EC, $ CC, $ DD, $ DC, $99, $ 9f, $ BB, $ B9, $33, $ 3E <br/> addr_00d8: <br/>; additional 8-byte data <br/>. DB $ 3c, $42, $ B9, $ A5, $ B9, $ A5, $42, $ 3C <br/>; ===== Nintendo logo comparison section =====< br/> addr_00e0: <br/> ld hl, $0104; $00e0; hl points to the Nintendo logo on the card <br/> LD de, $00a8; $00e3; de points to the Nintendo logo in DMG Rom <br/> addr_00e6: <br/> ld a, (de); $00e6 <br/> Inc de; $00e7 <br/> CP (HL); $00e8; compare the logo data on the card and DMG Rom <br/> Jr NZ, $ Fe; $00e9; if not, lock it here <br/> Inc HL; $ 00eb <br/> ld a, L; $ 00ec <br/> CP $34; $ 00ed; a total of $30 checks <br/> Jr NZ, addr_00e6; $ 00ef <br/> ld B, $19; $00f1 <br/> lD a, B; $00f3 <br/> addr_00f4: <br/> Add (HL ); $00f4 <br/> Inc HL; $00f5 <br/> dec B; $00f6 <br/> Jr NZ, addr_00f4; $00f7 <br/> Add (HL ); $00f9 <br/> Jr NZ, $ Fe; $ 00fa; if the sum of all the bytes from $0134 to $ 014d plus $19 is not 0, lock <br/> ld a, $01; $ 00fc <br/> LD ($ ff00 + $50), a; $ 00fe; Disable DMG Rom 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.