### Set Data Format Command Examples Source: https://wiki.neogeodev.org/index.php?action=edit&title=MESS_OUT Examples demonstrating how to configure data reading as bytes or words with either end codes or defined lengths. ```asm dc.w $0001,$15FF ;Data will be read in bytes, upper byte will always be $15, end code is $FF. dc.w $0101,$1520 ;Data will be read in bytes, upper byte will always be $15, data length is $20. dc.w $0201,$8000 ;Data will be read in words, end code is $8000. dc.w $0301,$2044 ;Data will be read in words, data length is $2044. ``` -------------------------------- ### HOW_TO_PLAY Example Command List (NAM-1975) Source: https://wiki.neogeodev.org/index.php?action=edit&title=HOW_TO_PLAY An example of a HOW_TO_PLAY command list used in the game NAM-1975, demonstrating various command types and their parameters. ```APIDOC ## HOW_TO_PLAY Example Command List (NAM-1975) ### Example ``` 0000 0200 ; All buttons released 0000 01FF ; All arrows highlighted 0010 F3E2 ; MESS_OUT write "NAM 1975" "CONTROL HERO AND CURSOR" 0004 ; Wait 4 frames 0000 000C ; Init loop counter to 12 0000 0100 ; All arrows cleared 0000 0000 ; Wait... 0008 ; ...8 frames 0000 01FF ; All arrows highlighted 0000 0000 ; Wait... 0008 ; ...8 frames 0000 00FF ; Loop back (blink all arrows 12 times) 0000 0201 ; A button is pressed 0000 0100 ; All arrows cleared 0010 F418 ; MESS_OUT write "MACHINE GUN" 0004 ; Wait 4 frames 0000 000C ; Init loop counter to 12 0000 0200 ; All buttons released 0000 0000 ; Wait... 0008 ; ...8 frames 0000 0201 ; A button is pressed 0000 0000 ; Wait... 0008 ; ...8 frames 0000 00FF ; Loop back (blink A button 12 times) ``` ``` -------------------------------- ### HOW_TO_PLAY Example Command List Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/HOW_TO_PLAY An example command list used by the game NAM-1975. It demonstrates setting button and joystick states, updating text via MESS_OUT, and implementing blinking effects using loop counters and wait commands. ```assembly 0000 0200 All buttons released 0000 01FF All arrows highlighted 0010 F3E2 MESS_OUT write "NAM 1975" "CONTROL HERO AND CURSOR" 0004 Wait 4 frames 0000 000C Init loop counter to 12 0000 0100 All arrows cleared <--------------, 0000 0000 Wait | 0008 ...8 frames | 0000 01FF All arrows highlighted | 0000 0000 Wait | 0008 ...8 frames | 0000 00FF Loop back (blink all arrows 12 times) --' 0000 0201 A button is pressed 0000 0100 All arrows cleared 0010 F418 MESS_OUT write "MACHINE GUN" 0004 Wait 4 frames 0000 000C Init loop counter to 12 0000 0200 All buttons released <--------------, 0000 0000 Wait... | 0008 ...8 frames | 0000 0201 A button is pressed | 0000 0000 Wait... | 0008 ...8 frames | 0000 00FF Loop back (blink A button 12 times) ----' ``` -------------------------------- ### Playing Sound Samples Example Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/Code Example code to play back V ROM sound samples on CH1 with maximum volume. ```assembly Example code to play back V ROM $000000-$00FFFF on CH1 with max volume. [[Category:Code]] ``` -------------------------------- ### BIOS Message System Example Source: https://wiki.neogeodev.org/index.php?action=edit&title=MESS_OUT Example code demonstrating how to use BIOS message output commands to display text and control VRAM addresses. Requires setup of message buffers and pointers. ```Assembly bset.b #0,BIOS_MESS_BUSY movea.l BIOS_MESS_POINT,a0 ;Get current pointer in buffer move.l #0,(a0)+ ;Direct commands move.w #3,(a0)+ move.w #$7318,(a0)+ move.w #$0301,(a0)+ move.w #0,(a0)+ move.w #$100000,(a0)+ move.w #0,(a0)+ move.l #MESSAGE1,(a0)+ move.l a0,BIOS_MESS_POINT bclr.b #0,BIOS_MESS_BUSY ;Ready to go rts ``` ```Assembly MESSAGE1: dc.w $0001 ;Bytes, upper = $00, end code = $FF dc.w $00FF dc.w $2002 ;Auto-inc = $20 dc.w $0003 ;VRAM address = $7024 dc.w $7024 dc.w $0004 ;Write "MESSAGE1" dc.l MS1 dc.w $0005 ;Next line dc.w $0001 dc.w $0006 ;Resume, write "MESSAGE2" dc.w $0005 ;Next line dc.w $0001 dc.w $0007 ;Direct data output dc.b "MESSAGE3" dc.w $FF00 ;End code and pad byte dc.w $0005 ;Next line dc.w $0001 dc.w $0108 ;8x16 write, fontset 1 dc.b "ABCDE",$FF dc.w $0005 ;Next line dc.w $0001 dc.w $0109 ;8x16 write, fontset 1 dc.b 0,1,2,3,4,$FF dc.w $0005 ;Next 2 lines dc.w $0002 dc.w $000A ;Sub list calls dc.l SUB_MESS dc.w $000A dc.l SUB_MESS dc.w $000A dc.l SUB_MESS dc.w $0000 ``` ```Assembly MS1: dc.b "MESSAGE 1",$FF dc.b "MESSAGE 2",$FF ``` ```Assembly SUB_MESS: dc.w $090C ;Outputs $0022 9 times dc.w $0022 dc.w $070D ;Outputs $0042 7 times with inc dc.w $0042 dc.w $0005 ;Next line dc.w $0001 dc.w $000B ;Return ``` -------------------------------- ### Set Data Format - Byte Mode Examples Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/MESS_OUT Examples demonstrating how to set the data format for byte-wise reading. These examples specify the upper byte for data and either an end code or a data length. ```Assembly dc.w $0001,$15FF ;Data will be read in bytes, upper byte will always be $15, end code is $FF. ``` ```Assembly dc.w $0101,$1520 ;Data will be read in bytes, upper byte will always be $15, data length is $20. ``` -------------------------------- ### Set Data Format - Word Mode Examples Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/MESS_OUT Examples showing how to configure the data format for word-wise reading. These commands set the data size or an end code when reading data in words. ```Assembly dc.w $0201,$8000 ;Data will be read in words, end code is $8000. ``` ```Assembly dc.w $0301,$2044 ;Data will be read in words, data length is $2044. ``` -------------------------------- ### NAM-1975 HOW_TO_PLAY Command List Example Source: https://wiki.neogeodev.org/index.php?action=edit&title=HOW_TO_PLAY A comprehensive example of a command list used by the game NAM-1975 for its 'how to play' screen. It includes initialization, button/arrow state changes, text displays, and loop structures. ```assembly 0000 0200 All buttons released 0000 01FF All arrows highlighted 0010 F3E2 MESS_OUT write "NAM 1975" "CONTROL HERO AND CURSOR" 0004 Wait 4 frames 0000 000C Init loop counter to 12 0000 0100 All arrows cleared <--------------, 0000 0000 Wait... | 0000 0000 Wait... | 0008 ...8 frames | 0008 ...8 frames | 0000 01FF All arrows highlighted | 0000 0201 A button is pressed | 0000 0000 Wait... | 0000 0000 Wait... | 0008 ...8 frames | 0008 ...8 frames | 0000 00FF Loop back (blink all arrows 12 times) --' 0000 0201 A button is pressed 0000 0100 All arrows cleared 0010 F418 MESS_OUT write "MACHINE GUN" 0004 Wait 4 frames 0000 000C Init loop counter to 12 0000 0200 All buttons released <--------------, 0000 0000 Wait... | 0000 0000 Wait... | 0008 ...8 frames | 0008 ...8 frames | 0000 0201 A button is pressed | 0000 0201 A button is pressed | 0000 0000 Wait... | 0000 0000 Wait... | 0008 ...8 frames | 0008 ...8 frames | 0000 00FF Loop back (blink A button 12 times) ----' ``` -------------------------------- ### Example P bus values for sprites starting at X=0 Source: https://wiki.neogeodev.org/index.php/Rendering_logic Provides example P bus values for five full-width sprites positioned consecutively starting at the X-coordinate 0. ```assembly 0000,0808,1010,1818,2020 ``` -------------------------------- ### Software DIPs Configuration Example (No Special Settings) Source: https://wiki.neogeodev.org/index.php?action=edit&title=Software_DIPs This example demonstrates the structure for defining game name, special settings list (none used), simple settings list, and their corresponding string descriptions and choices. Unused special settings are marked with $FFFF. ```assembly dc.b "TEST ROM " ; Game name dc.w $FFFF ; Special settings list (none used) dc.w $FFFF dc.b $FF,$FF dc.b $24 ; Simple setting 1: 4 choices, default is #2 dc.b $02 ; Simple setting 2: 2 choices, default is #0 dc.b $00,$00,$00,$00,$00,$00,$00,$00 ; String table: dc.b "LIVES " ; Simple setting 1's description dc.b "1 " ; Simple setting 1's choices dc.b "2 " dc.b "3 " dc.b "4 " dc.b "HOW TO PLAY " ; Simple setting 2's description dc.b "WITH " ; Simple setting 2's choices dc.b "WITHOUT " ``` -------------------------------- ### Example P bus values for sprites starting at X=1 Source: https://wiki.neogeodev.org/index.php/Rendering_logic Illustrates P bus values for five full-width sprites placed adjacently starting at X=1. Note that NEO-ZMC2 may flip pixel pairs. ```assembly 0100,0908,1110,1918,2120 ``` -------------------------------- ### Calculate Bankswitching Address Source: https://wiki.neogeodev.org/index.php?action=edit&title=NEO-PVC Example calculation for determining the mapped data start address based on values written to the bankswitching registers. ```text if $0131 is written to $2FFFF2, and $2A00 is written to $2FFFF0, the data mapped starts at $11312A. ``` -------------------------------- ### CD Boot Process Initialization Steps Source: https://wiki.neogeodev.org/index.php?action=edit&title=Boot_process Outlines the initial steps for the CD boot process, including initializing RAM, loading the BIOS vector table, disabling interrupts, loading graphics data, and finally enabling interrupts. ```assembly Init RAM ``` ```assembly Load BIOS vector table ``` ```assembly Disable interrupts ``` ```assembly Load DRAMs with graphics & stuff ``` ```assembly Enable interrupts ``` -------------------------------- ### P bus values for sprite positioning Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/Rendering_logic Examples of P bus values used to set sprite starting addresses for full-width sprites. ```text 0000,0808,1010,1818,2020 ``` ```text 0100,0908,1110,1918,2120 ``` -------------------------------- ### CD Drive Command 2: TOC COMMAND - GET TRACK MSF Source: https://wiki.neogeodev.org/index.php?action=edit&title=CD_drive_commands Retrieves the start MSF of a desired track. The upper digit of the frames' 4th bit indicates if it's a data track. Requires sub-command code 5. ```hex 20 00 00 05 ?? 00 00 00 00 ? ``` ```hex ? 5 ???????? ? ? ``` -------------------------------- ### Command 13: OPEN Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/CD_drive_commands Opens the tray on the front-loading NeoGeo CD. ```APIDOC ## OPEN ### Description Opens the tray on the front-loading NeoGeo CD. ### Request Body - **Nibbles** (array) - Required - A sequence of 10 nibbles: [13, 0, 0, 0, 0, 0, 0, 0, 0, Checksum(D)] ``` -------------------------------- ### Initialize Game Environment Source: https://wiki.neogeodev.org/index.php?action=edit&title=Hello_world_tutorial Sets up the stack pointer, kicks the watchdog, disables the pixel timer, clears interrupts, and enables system interrupts. ```assembly Game: ; Label defined in the jump table lea $10F300,sp ; Init stack pointer move.b d0,REG_DIPSW ; Kick watchdog move.w #$0000,REG_LSPCMODE ; Make sur the pixel timer is disabled move.w #7,REG_IRQACK ; Clear all interrupts move.w #$2000,sr ; Enable interrupts ``` -------------------------------- ### Example Tone Frequency Calculation Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/SSG Example calculation for Note A4 (440Hz) to determine the required value. ```plaintext Example: Note A4 (440Hz) would be 250000 / 440 =~ 568 = $238. ``` -------------------------------- ### Command 0x3* and 0xa* Write Setup Source: https://wiki.neogeodev.org/index.php/HD6301V1 Sets up a write operation for lower nibble values, checking for buffer selection. ```Assembly F3B7: B6 00 E7 lda $00E7 ;a=$e7 F3BA: 81 FF cmpa #$FF ;==0xff? F3BC: 27 18 beq $F3D6 ;yes? => branch $f3d6 //branch to error if $e7==0xff (no buffer selected) F3BE: B6 00 E9 lda $00E9 ;a=$e9 //port3 data F3C1: 84 0F anda #$0F ;a&=0x0f F3C3: B7 00 F3 sta $00F3 ;$f3=a //store lower nibble F3C6: 71 EF F1 aim #$EF,$F1 ;$f1&=0xef //clear bit#4 F3C9: B6 00 F1 lda $00F1 ;a=$f1 F3CC: 97 02 sta $02 ;port1=a //update status port F3CE: 86 FF lda #$FF ;a=0xff F3D0: B7 00 F2 sta $00F2 ;$f2=a //$f2=0xff F3D3: 7E F1 93 jmp $F193 ;branch $f193 ``` -------------------------------- ### MGD2 ROM Filename Examples Source: https://wiki.neogeodev.org/index.php?action=edit&title=MGD2 Examples of MGD2 ROM filenames demonstrating size, serial, and upload address encoding. ```text N042001A.038 ``` ```text N028015B.27C ``` -------------------------------- ### Command 10: INIT Source: https://wiki.neogeodev.org/index.php/CD_drive_commands Initializes the CD drive, potentially seeking to the CD lead-in area. ```APIDOC ## INIT Command ### Description Initializes the CD drive. This command may seek to the CD lead-in area. ### Method N/A (Command-based) ### Endpoint N/A (Command-based) ### Parameters None specified ### Request Example (Format not fully specified, but likely starts with command nibble) ``` Nibble | 0 | ... ---|---|--- Value | 10 | ... ``` ### Response None specified ``` -------------------------------- ### Neo Turf Masters Example Source: https://wiki.neogeodev.org/index.php/Timer_interrupt An example illustrating the use of timer interrupts in Neo Turf Masters for graphical effects. ```APIDOC ## Example: Neo Turf Masters ### Description This section provides a practical example of how timer interrupts are utilized in the game Neo Turf Masters to achieve specific graphical effects, such as perspective scrolling and line-based updates. ### Method N/A (Usage Example) ### Endpoint N/A (Usage Example) ### Scenario Breakdown: - **A: Frame Start** - The timer is reloaded with a value of 41016. - The next interrupt is scheduled to trigger at point B, approximately 106 lines and 313 pixels into the frame. - This timing is used to set the scroll value for background elements like mountains. - **B: Ground Area Start** - The timer is immediately reloaded to 767. - The timer mode is set to "reload when 0 is reached". - This configuration triggers interrupts every 2 lines, allowing for dynamic updates to the ground graphics to simulate a perspective effect. - A variable is used to track the number of ground lines rendered. - **C: Ground Area End** - Once the required number of ground lines are rendered, the timer is immediately reloaded to 16383. - The timer mode is changed to "reload on first line of next frame". - The reload value is set to 41016, ensuring the next interrupt occurs later in the frame cycle. ``` -------------------------------- ### Game Configuration with Time and Count Settings Source: https://wiki.neogeodev.org/index.php/Software_DIPs Example of a game configuration including time and count special settings, along with simple settings. Demonstrates default values for time (minutes/seconds) and count (0-100). ```assembly dc.b "TEST ROM "  ; Game name dc.w $4220  ; Special setting 1: 42 minutes 20 seconds dc.w $2042  ; Special setting 2: 20 minutes 42 seconds dc.b $42  ; Special setting 3: 66 dc.b $64  ; Special setting 4: 100 ("INFINITE") dc.b $24  ; Simple setting 1: 4 choices, default is #2 dc.b $02  ; Simple setting 2: 2 choices, default is #0 dc.b $00,$00,$00,$00,$00,$00,$00,$00 dc.b "TIMER 1 "  ; Special setting 1's description dc.b "TIMER 2 "  ; Special setting 2's description dc.b "COUNTER "  ; Special setting 3's description dc.b "COUNTER SPE "  ; Special setting 4's description dc.b "LIVES "  ; Simple setting 1's description dc.b "1 "  ; Simple setting 1's choices dc.b "2 " dc.b "3 " dc.b "4 " dc.b "HOW TO PLAY "  ; Simple setting 2's description dc.b "WITH "  ; Simple setting 2's choices dc.b "WITHOUT " ``` -------------------------------- ### Real-time Fading Code Example Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/Graphics_Code An example of code demonstrating real-time color fading by incrementing or decrementing target colors. ```Assembly =Real-time fading code= ... ``` -------------------------------- ### CONTROLLER_SETUP ($C004D4) Source: https://wiki.neogeodev.org/index.php?action=edit&title=CONTROLLER_SETUP The CONTROLLER_SETUP routine initializes controller configurations and updates the status bytes in BIOS RAM. It performs a series of checks to identify connected hardware. ```APIDOC ## CONTROLLER_SETUP ($C004D4) ### Description Sets up controllers by detecting connected devices and updating the input status byte in BIOS RAM. Note that register contents are not preserved. ### Status Byte Values - **0**: No connection (treated as standard controller) - **1**: Standard controller - **2**: Expanded controller (4P mode) - **3**: Mahjong controller - **4**: Keyboard ### MVS Logic - If hard dip 3 is set, BIOS_P1STATUS is set to 3. - Otherwise, status byte is set to 0 for all players. ### Neo Geo / Neo Geo CD Logic - Performs 6 consecutive checks regardless of previous matches. - Status bytes are only updated if the current value is 0 (1st check has highest priority). - Detection involves writing configurations to controller outputs and checking specific buttons (D, C, Select, Start). ``` -------------------------------- ### Initialize User RAM for Command 0 Source: https://wiki.neogeodev.org/index.php/USER_subroutine Example of clearing backup RAM and initializing system variables during the Command 0 initialization phase. ```68k Assembly move.b #$00,BIOS_USER_MODE lea $100000,a0 ;Start of game save block move #$001F,d1 ;32*4 longword writes = 512 bytes moveq #0,d0 .cl: move.l d0,(a0)+ move.l d0,(a0)+ move.l d0,(a0)+ move.l d0,(a0)+ dbf d1,.cl move.b d0,REG_WATCHDOG ... jmp BIOSF_SYSTEM_RETURN ``` -------------------------------- ### Example NGH Number in 68k Assembly Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/NGH An example of how an NGH number might be represented in 68k assembly code, often as a word value. ```assembly dc.w $1234 ;NGH ``` -------------------------------- ### Art of Fighting 3 IPL.TXT example Source: https://wiki.neogeodev.org/index.php/IPL_file Example of an IPL.TXT file from Art of Fighting 3, including hex representations of character values. ```text FIX_CD.FIX,0,00 46 49 58 5F 43 44 2E 46 49 58 2C 30 2C 30 30 0D 0A PROG_CD.PRG,0,0 50 52 4F 47 5F 43 44 2E 50 52 47 2C 30 2C 30 0D 0A PROG_CDX.PRG,0,058000 50 52 4F 47 5F 43 44 58 2E 50 52 47 2C 30 2C 30 35 38 30 30 30 0D 0A FIX_DATA.PRG,0,0FD000 46 49 58 5F 44 41 54 41 2E 50 52 47 2C 30 2C 30 46 44 30 30 30 0D 0A CNV_NM.PRG,0,0C0000 43 4E 56 5F 4E 4D 2E 50 52 47 2C 30 2C 30 43 30 30 30 30 0D 0A HITMSG.PRG,0,170000 48 49 54 4D 53 47 2E 50 52 47 2C 30 2C 31 37 30 30 30 30 0D 0A OBJACTLK.PRG,0,130000 4F 42 4A 41 43 54 4C 4B 2E 50 52 47 2C 30 2C 31 33 30 30 30 30 0D 0A SSEL_CNV.PRG,0,15A000 53 53 45 4C 5F 43 4E 56 2E 50 52 47 2C 30 2C 31 35 41 30 30 30 0D 0A SSEL_BAK.PRG,0,16F000 53 53 45 4C 5F 42 41 4B 2E 50 52 47 2C 30 2C 31 36 46 30 30 30 0D 0A SSEL_SPR.PRG,0,19D000 53 53 45 4C 5F 53 50 52 2E 50 52 47 2C 30 2C 31 39 44 30 30 30 0D 0A SND8V1CD.Z80,0,0 53 4E 44 38 56 31 43 44 2E 5A 38 30 2C 30 2C 30 0D 0A JYOU.PCM,0,0 4A 59 4F 55 2E 50 43 4D 2C 30 2C 30 0D 0A JYOU.PAT,0,0 4A 59 4F 55 2E 50 41 54 2C 30 2C 30 0D 0A 1A ``` -------------------------------- ### Command 0xc* Buffer Copy and Write Setup Source: https://wiki.neogeodev.org/index.php/HD6301V1 Copies storage buffer data and prepares for a subsequent 0x0d data write. ```Assembly F426: B6 00 E7 lda $00E7 ;a=$e7 F429: 81 FF cmpa #$FF ;a==0xff? F42B: 27 A9 beq $F3D6 ;yes? => branch f3d6 //error F42D: B6 00 E9 lda $00E9 ;a=$e9 //port3 data F430: 16 tab ;b=a F431: 84 0C anda #$0C ;a&=0x0c //keep bit#3 & bit#2 F433: 26 A1 bne $F3D6 ;!=0? => branch $f3d6 //error F435: 71 EF F1 aim #$EF,$F1 ;$f1&=0xef //clear bit#4 F438: B6 00 F1 lda $00F1 ;$a=f1 F43B: 97 02 sta $02 ;port1=a //update status port F43D: C4 03 andb #$03 ;b&=0x03 //keep bit#1 & bit#0 F43F: CE F4 FA ldx #$F4FA ;x=data table F442: 3A abx ;x+=b F443: 3A abx ;x+=b F444: EE 00 ldx (x+$00) ;x=(word)data[b] //buffer addr ``` -------------------------------- ### Command 0: Initialize User RAM and Peripherals Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/USER_subroutine This snippet initializes the game's backup RAM with default data, sets up user RAM, display, and I/O. It's crucial to set BIOS_USER_MODE to 0 and kick the watchdog as interrupts are disabled during this process. The code clears a specified block of memory. ```68k Assembly move.b #$00,BIOS_USER_MODE lea $100000,a0 ;Start of game save block move #$001F,d1 ;32*4 longword writes = 512 bytes moveq #0,d0 .cl: move.l d0,(a0)+ move.l d0,(a0)+ move.l d0,(a0)+ move.l d0,(a0)+ dbf d1,.cl move.b d0,REG_WATCHDOG ... jmp BIOSF_SYSTEM_RETURN ``` -------------------------------- ### ADPCM-A Playback Example Source: https://wiki.neogeodev.org/index.php/Special%3ASearch/Playing_sound_samples Example code to play back ADPCM-A samples from V ROM. It sets volume, start/end addresses, and initiates playback on a specified channel. ```assembly ;playback parameters CHMASK: equ $01 MVOL: equ $3F CVOL: equ $C0+$1F START: equ $0000 END: equ $00FF PlayADPCMA: ld de,PA_MVOL<<8 +MVOL ;master volume rst $18 ld de,PA_CVOL<<8 +CVOL ;left/right/channel volume rst $18 ld de,PA_STARTL<<8 +START AND $FF ;start address low rst $18 ld de,PA_STARTH<<8 +START / $100 ;start address high rst $18 ld de,PA_ENDL<<8 +END AND $FF ;end address low rst $18 ld de,PA_ENDH<<8 +END / $100 ;end address high rst $18 ld de,PA_CTRL<<8 +CHMASK ;play this channel rst $18 ret ```