Specifying the .sym format

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Specifying the .sym format

Post by tepples »

The .sym file format is used by the debugging features of NO$GMB and bgb emulators. WLALINK and RGBLINK generate this format, and the mgbdis disassembler accepts it as input. Each nonblank line contains either a semicolon and comment or a bank (1-3 hex digits), colon, address (4 hex digits), whitespace, and a symbol name. An example is below:

Code: Select all

; File generated by rgblink

00:06D5 run_dma_master
00:06DF run_dma_end
00:06C8 memcpy
00:06BF memset.loop
00:06CB memcpy.loop
00:06DB run_dma_master.loop
00:06BB memset
00:0694 reset_handler
00:0008 memset_tiny_impl
00:0019 memset_inc
00:0049 wait_vblank_irq_tail
00:0760 lcd_off
00:0010 wait_vblank_irq_impl
00:00F4 busy_wait_vblank
00:00F8 busy_wait_vblank.wait
00:0001 wait_not_vblank
00:0757 clear_scrn0_to_h
00:0755 clear_scrn0_to_0
00:0742 load_nam.byteloop
00:0750 load_nam.no_inc_d
00:0740 load_nam
00:073D load_full_nam
00:072C read_pad.onenibble
00:070F read_pad
00:05BD apucmd_reset_apu
00:04A7 load_apucmd_de
00:04C8 mdfourier_present
00:0607 waveram_sinx
00:04B7 load_waveram_hl
00:04E5 pattern_sync
00:0528 pattern_tone_scale_duty_c
00:0559 pattern_noise_scale_duty_c
00:057A pattern_steady_noise
00:05F5 apucmd_pulse_reset_lo
00:058D pattern_pulse_reset_de
00:05FE apucmd_pulse_reset_hi
00:059F pattern_sweep_up_duty_c
00:04B1 apu_stpcpy
00:04AC apu_stpcpyloop
00:04BD load_waveram_hl.loop
00:04D3 mdfourier_push_apubuffer.loopcontinue
00:04D0 mdfourier_push_apubuffer.loop
00:04FD silence_20_frames
00:05D8 apucmd_sync_tone
00:04FF silence_b_frames
00:04EA pattern_sync.loop
00:05C7 apucmd_silence
00:0505 wait_b_frames
00:0519 load_note_start_duty_c.notwave1
00:05E3 apucmd_wave_tone
00:050E load_note_start_duty_c
00:04DB hl_index_a
00:052F pattern_tone_scale_duty_c.loop
00:05EE apucmd_noise_tone
00:055D pattern_noise_scale_duty_c.loop
00:058F pattern_pulse_reset_de.loop
00:0554 silence_10_frames
00:05A4 pattern_sweep_up_duty_c.loop
00:045A run_mdfourier
00:0617 waveram_sin2x
00:018C title_iur
00:017A return_to_title.waitloop
00:015A return_to_title
00:0150 main
00:06EA pb16_unpack_packet.p0_is_literal
00:06EE pb16_unpack_packet.have_p0
00:06F7 pb16_unpack_packet.have_p1
00:06E4 pb16_unpack_packet.byteloop
00:06DF pb16_unpack_packet
00:0701 pb16_unpack_block.packetloop
00:06FD pb16_unpack_block
00:065A iur_unpack.byteloop
00:0662 iur_unpack.nonewbyte_0
00:0679 iur_unpack.do_runtype_a
00:066E iur_unpack.nonewbyte_1
00:0685 iur_unpack.write_byte_a
00:0683 iur_unpack.is_repeat
00:0637 unpack_iu_file
00:063F iur_unpack_2hl_bytes
00:064A iur_unpack
00:0640 iur_unpack_2a_bytes
00:0062 pitch_table
00:C0A4 stack_top
00:C0A1 initial_a
00:C0A2 initial_b
00:C0A0 oam_used
00:C000 SOAM
00:C0E4 apubuffer
00:FFF4 run_dma
00:FF92 hw_capability
00:FF93 nmis
00:FF90 cur_keys
00:FF91 new_keys
ISSOtm now wants to create a formal specification for this format. How exactly do existing emulators that accept .sym files interpret them?
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: Specifying the .sym format

Post by jeffythedragonslayer »

Like this:

Code: Select all

		public static void LoadSymFile(string path, bool showResult)
		{
			if(File.Exists(path) && Path.GetExtension(path).ToLower() == "." + FileDialogHelper.SymFileExt) {
				ResetLabels();

				string symContent = File.ReadAllText(path);
				if(symContent.Contains("[labels]")) {
					//Assume WLA-DX symbol files
					if(_romInfo.ConsoleType == ConsoleType.Snes || _romInfo.CpuTypes.Contains(CpuType.Gameboy)) {
						WlaDxImporter importer = new();
						importer.Import(path, showResult);
						SymbolProvider = importer;
					}
				} else {
					if(_romInfo.CpuTypes.Contains(CpuType.Gameboy)) {
						if(RgbdsSymbolFile.IsValidFile(path)) {
							RgbdsSymbolFile.Import(path, showResult);
						} else {
							BassLabelFile.Import(path, showResult, CpuType.Gameboy);
						}
					} else {
						BassLabelFile.Import(path, showResult, _romInfo.ConsoleType.GetMainCpuType());
					}
				}
			}
		}
source: https://github.com/SourMesen/Mesen2/blo ... Manager.cs
Post Reply