Preparation for future AGB-0 and B support

This commit is contained in:
Lior Halphon 2022-01-30 18:11:35 +02:00
parent 4bebd2bc33
commit a7f7530eed
10 changed files with 82 additions and 55 deletions

View File

@ -326,11 +326,11 @@
<point key="canvasLocation" x="-501" y="236.5"/> <point key="canvasLocation" x="-501" y="236.5"/>
</customView> </customView>
<customView id="ymk-46-SX7"> <customView id="ymk-46-SX7">
<rect key="frame" x="0.0" y="0.0" width="320" height="375"/> <rect key="frame" x="0.0" y="0.0" width="320" height="427"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="w9w-yX-KxB"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="w9w-yX-KxB">
<rect key="frame" x="18" y="283" width="284" height="17"/> <rect key="frame" x="18" y="335" width="284" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Rewinding duration:" id="JaO-5h-ugl"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Rewinding duration:" id="JaO-5h-ugl">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
@ -339,7 +339,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="o3Z-34-FJk"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="o3Z-34-FJk">
<rect key="frame" x="18" y="228" width="280" height="17"/> <rect key="frame" x="18" y="280" width="280" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Real Time Clock emulation:" id="Qoi-ub-YtI"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Real Time Clock emulation:" id="Qoi-ub-YtI">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
@ -348,7 +348,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MI2-ql-f6M"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MI2-ql-f6M">
<rect key="frame" x="18" y="338" width="284" height="17"/> <rect key="frame" x="18" y="390" width="284" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Boot ROMs location:" id="nj0-Cb-gEA"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Boot ROMs location:" id="nj0-Cb-gEA">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
@ -357,7 +357,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wg8-hJ-df9"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wg8-hJ-df9">
<rect key="frame" x="18" y="160" width="284" height="17"/> <rect key="frame" x="18" y="212" width="284" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Game Boy revision:" id="GIA-ep-SBi"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Game Boy revision:" id="GIA-ep-SBi">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
@ -366,7 +366,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LFw-Uk-cPR"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LFw-Uk-cPR">
<rect key="frame" x="30" y="127" width="262" height="26"/> <rect key="frame" x="30" y="179" width="262" height="26"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="DMG-CPU B" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="2" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="aXT-sE-m5Z" id="FuX-Hc-uO7"> <popUpButtonCell key="cell" type="push" title="DMG-CPU B" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="2" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="aXT-sE-m5Z" id="FuX-Hc-uO7">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@ -385,7 +385,7 @@
</connections> </connections>
</popUpButton> </popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MAq-1X-Gpo"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MAq-1X-Gpo">
<rect key="frame" x="16" y="50" width="284" height="17"/> <rect key="frame" x="16" y="102" width="284" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Game Boy Color revision:" id="edD-t7-vwk"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Game Boy Color revision:" id="edD-t7-vwk">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
@ -394,19 +394,19 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dlD-sk-SHO"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dlD-sk-SHO">
<rect key="frame" x="28" y="17" width="262" height="26"/> <rect key="frame" x="28" y="69" width="262" height="26"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="CPU-CGB E" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="517" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="3lF-1Q-2SS" id="Edt-1S-dXz"> <popUpButtonCell key="cell" type="push" title="CPU CGB E" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="517" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="3lF-1Q-2SS" id="Edt-1S-dXz">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/> <font key="font" metaFont="menu"/>
<menu key="menu" autoenablesItems="NO" id="bbF-hB-Hv7"> <menu key="menu" autoenablesItems="NO" id="bbF-hB-Hv7">
<items> <items>
<menuItem title="CPU-CGB 0 (Experimental)" tag="512" id="2Uk-u3-6Gw"/> <menuItem title="CPU CGB 0 (Experimental)" tag="512" id="2Uk-u3-6Gw"/>
<menuItem title="CPU-CGB A (Experimental)" tag="513" id="axv-yk-RWM"/> <menuItem title="CPU CGB A (Experimental)" tag="513" id="axv-yk-RWM"/>
<menuItem title="CPU-CGB B (Experimental)" tag="514" id="NtJ-oo-IM2"/> <menuItem title="CPU CGB B (Experimental)" tag="514" id="NtJ-oo-IM2"/>
<menuItem title="CPU-CGB C (Experimental)" tag="515" id="9YL-u8-12z"/> <menuItem title="CPU CGB C (Experimental)" tag="515" id="9YL-u8-12z"/>
<menuItem title="CPU-CGB D" tag="516" id="c76-oF-fkU"/> <menuItem title="CPU CGB D" tag="516" id="c76-oF-fkU"/>
<menuItem title="CPU-CGB E" state="on" tag="517" id="3lF-1Q-2SS"/> <menuItem title="CPU CGB E" state="on" tag="517" id="3lF-1Q-2SS"/>
</items> </items>
</menu> </menu>
</popUpButtonCell> </popUpButtonCell>
@ -415,7 +415,7 @@
</connections> </connections>
</popUpButton> </popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tAa-0A-0fP"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tAa-0A-0fP">
<rect key="frame" x="18" y="105" width="284" height="17"/> <rect key="frame" x="18" y="157" width="284" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Super Game Boy model:" id="d0g-rk-FK0"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Super Game Boy model:" id="d0g-rk-FK0">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
@ -424,11 +424,11 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="mdm-eW-ia1"> <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="mdm-eW-ia1">
<rect key="frame" x="12" y="183" width="296" height="5"/> <rect key="frame" x="12" y="235" width="296" height="5"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
</box> </box>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dza-T7-RkX"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dza-T7-RkX">
<rect key="frame" x="28" y="72" width="262" height="26"/> <rect key="frame" x="28" y="124" width="262" height="26"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Super Game Boy (NTSC)" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="4" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="x5A-7f-ef9" id="2Mt-ci-bB0"> <popUpButtonCell key="cell" type="push" title="Super Game Boy (NTSC)" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="4" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="x5A-7f-ef9" id="2Mt-ci-bB0">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@ -446,7 +446,7 @@
</connections> </connections>
</popUpButton> </popUpButton>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tFf-H1-XUL"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tFf-H1-XUL">
<rect key="frame" x="30" y="199" width="262" height="22"/> <rect key="frame" x="30" y="251" width="262" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Sync to system clock" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="arp-Qi-Xix" id="uRs-Ag-Sbw"> <popUpButtonCell key="cell" type="push" title="Sync to system clock" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="arp-Qi-Xix" id="uRs-Ag-Sbw">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@ -465,7 +465,7 @@
</connections> </connections>
</popUpButton> </popUpButton>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wC4-aJ-mhQ"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wC4-aJ-mhQ">
<rect key="frame" x="30" y="305" width="262" height="26"/> <rect key="frame" x="30" y="357" width="262" height="26"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Use built-in boot ROMs" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Tnm-SR-ZEm" id="T3Y-Ln-Onl"> <popUpButtonCell key="cell" type="push" title="Use built-in boot ROMs" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Tnm-SR-ZEm" id="T3Y-Ln-Onl">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@ -489,7 +489,7 @@
</popUpButtonCell> </popUpButtonCell>
</popUpButton> </popUpButton>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7fg-Ww-JjR"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7fg-Ww-JjR">
<rect key="frame" x="30" y="250" width="262" height="26"/> <rect key="frame" x="30" y="302" width="262" height="26"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Disabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="lxQ-4n-kEv" id="lvb-QF-0Ht"> <popUpButtonCell key="cell" type="push" title="Disabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="lxQ-4n-kEv" id="lvb-QF-0Ht">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@ -512,8 +512,32 @@
<action selector="rewindLengthChanged:" target="QvC-M9-y7g" id="5NQ-1T-RNc"/> <action selector="rewindLengthChanged:" target="QvC-M9-y7g" id="5NQ-1T-RNc"/>
</connections> </connections>
</popUpButton> </popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5r5-qY-b8h">
<rect key="frame" x="18" y="47" width="280" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Game Boy Advance revision:" id="R5q-dJ-NvD">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Dl-S6-O7c">
<rect key="frame" x="30" y="17" width="257" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="CPU AGB A" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="519" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="8bk-wP-Cbr" id="EhC-I2-5Th">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" autoenablesItems="NO" id="b2b-jo-SrI">
<items>
<menuItem title="CPU AGB 0" tag="518" enabled="NO" id="75z-Yy-XaY"/>
<menuItem title="CPU AGB A" state="on" tag="519" id="8bk-wP-Cbr"/>
<menuItem title="CPU AGB B (Game Boy Advance SP)" tag="520" enabled="NO" id="jIE-v4-768"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
</subviews> </subviews>
<point key="canvasLocation" x="-501" y="667.5"/> <point key="canvasLocation" x="-501" y="693.5"/>
</customView> </customView>
<customView id="Zn1-Y5-RbR"> <customView id="Zn1-Y5-RbR">
<rect key="frame" x="0.0" y="0.0" width="320" height="201"/> <rect key="frame" x="0.0" y="0.0" width="320" height="201"/>

View File

@ -21,7 +21,7 @@ static void refresh_channel(GB_gameboy_t *gb, unsigned index, unsigned cycles_of
bool GB_apu_is_DAC_enabled(GB_gameboy_t *gb, unsigned index) bool GB_apu_is_DAC_enabled(GB_gameboy_t *gb, unsigned index)
{ {
if (gb->model >= GB_MODEL_AGB) { if (gb->model > GB_MODEL_CGB_E) {
/* On the AGB, mixing is done digitally, so there are no per-channel /* On the AGB, mixing is done digitally, so there are no per-channel
DACs. Instead, all channels are summed digital regardless of DACs. Instead, all channels are summed digital regardless of
whatever the DAC state would be on a CGB or earlier model. */ whatever the DAC state would be on a CGB or earlier model. */
@ -68,12 +68,12 @@ static uint8_t agb_bias_for_channel(GB_gameboy_t *gb, unsigned index)
static void update_sample(GB_gameboy_t *gb, unsigned index, int8_t value, unsigned cycles_offset) static void update_sample(GB_gameboy_t *gb, unsigned index, int8_t value, unsigned cycles_offset)
{ {
if (gb->model >= GB_MODEL_AGB && index == GB_WAVE) { if (gb->model > GB_MODEL_CGB_E && index == GB_WAVE) {
/* For some reason, channel 3 is inverted on the AGB */ /* For some reason, channel 3 is inverted on the AGB */
value ^= 0xF; value ^= 0xF;
} }
if (gb->model >= GB_MODEL_AGB) { if (gb->model > GB_MODEL_CGB_E) {
/* On the AGB, because no analog mixing is done, the behavior of NR51 is a bit different. /* On the AGB, because no analog mixing is done, the behavior of NR51 is a bit different.
A channel that is not connected to a terminal is idenitcal to a connected channel A channel that is not connected to a terminal is idenitcal to a connected channel
playing PCM sample 0. */ playing PCM sample 0. */
@ -145,7 +145,7 @@ static signed interference(GB_gameboy_t *gb)
/* These aren't scientifically measured, but based on ear based on several recordings */ /* These aren't scientifically measured, but based on ear based on several recordings */
signed ret = 0; signed ret = 0;
if (gb->halted) { if (gb->halted) {
if (gb->model != GB_MODEL_AGB) { if (gb->model <= GB_MODEL_CGB_E) {
ret -= MAX_CH_AMP / 5; ret -= MAX_CH_AMP / 5;
} }
else { else {
@ -154,7 +154,7 @@ static signed interference(GB_gameboy_t *gb)
} }
if (gb->io_registers[GB_IO_LCDC] & 0x80) { if (gb->io_registers[GB_IO_LCDC] & 0x80) {
ret += MAX_CH_AMP / 7; ret += MAX_CH_AMP / 7;
if ((gb->io_registers[GB_IO_STAT] & 3) == 3 && gb->model != GB_MODEL_AGB) { if ((gb->io_registers[GB_IO_STAT] & 3) == 3 && gb->model <= GB_MODEL_CGB_E) {
ret += MAX_CH_AMP / 14; ret += MAX_CH_AMP / 14;
} }
else if ((gb->io_registers[GB_IO_STAT] & 3) == 1) { else if ((gb->io_registers[GB_IO_STAT] & 3) == 1) {
@ -166,7 +166,7 @@ static signed interference(GB_gameboy_t *gb)
ret += MAX_CH_AMP / 10; ret += MAX_CH_AMP / 10;
} }
if (GB_is_cgb(gb) && gb->model < GB_MODEL_AGB && (gb->io_registers[GB_IO_RP] & 1)) { if (GB_is_cgb(gb) && gb->model <= GB_MODEL_CGB_E && (gb->io_registers[GB_IO_RP] & 1)) {
ret += MAX_CH_AMP / 10; ret += MAX_CH_AMP / 10;
} }
@ -186,7 +186,7 @@ static void render(GB_gameboy_t *gb)
unrolled for (unsigned i = 0; i < GB_N_CHANNELS; i++) { unrolled for (unsigned i = 0; i < GB_N_CHANNELS; i++) {
double multiplier = CH_STEP; double multiplier = CH_STEP;
if (gb->model < GB_MODEL_AGB) { if (gb->model <= GB_MODEL_CGB_E) {
if (!GB_apu_is_DAC_enabled(gb, i)) { if (!GB_apu_is_DAC_enabled(gb, i)) {
gb->apu_output.dac_discharge[i] -= ((double) DAC_DECAY_SPEED) / gb->apu_output.sample_rate; gb->apu_output.dac_discharge[i] -= ((double) DAC_DECAY_SPEED) / gb->apu_output.sample_rate;
if (gb->apu_output.dac_discharge[i] < 0) { if (gb->apu_output.dac_discharge[i] < 0) {
@ -284,7 +284,7 @@ static void render(GB_gameboy_t *gb)
static void update_square_sample(GB_gameboy_t *gb, unsigned index) static void update_square_sample(GB_gameboy_t *gb, unsigned index)
{ {
if (gb->apu.square_channels[index].sample_surpressed) { if (gb->apu.square_channels[index].sample_surpressed) {
if (gb->model >= GB_MODEL_AGB) { if (gb->model > GB_MODEL_CGB_E) {
update_sample(gb, index, gb->apu.samples[index], 0); update_sample(gb, index, gb->apu.samples[index], 0);
} }
return; return;
@ -533,7 +533,7 @@ void GB_apu_div_event(GB_gameboy_t *gb)
if (gb->apu.wave_channel.length_enabled) { if (gb->apu.wave_channel.length_enabled) {
if (gb->apu.wave_channel.pulse_length) { if (gb->apu.wave_channel.pulse_length) {
if (!--gb->apu.wave_channel.pulse_length) { if (!--gb->apu.wave_channel.pulse_length) {
if (gb->apu.is_active[GB_WAVE] && gb->model == GB_MODEL_AGB) { if (gb->apu.is_active[GB_WAVE] && gb->model > GB_MODEL_CGB_E) {
if (gb->apu.wave_channel.sample_countdown == 0) { if (gb->apu.wave_channel.sample_countdown == 0) {
gb->apu.wave_channel.current_sample_byte = gb->apu.wave_channel.current_sample_byte =
gb->io_registers[GB_IO_WAV_START + (((gb->apu.wave_channel.current_sample_index + 1) & 0xF) >> 1)]; gb->io_registers[GB_IO_WAV_START + (((gb->apu.wave_channel.current_sample_index + 1) & 0xF) >> 1)];
@ -612,7 +612,7 @@ void GB_apu_run(GB_gameboy_t *gb, bool force)
(gb->apu.apu_cycles > 0x1000) || (gb->apu.apu_cycles > 0x1000) ||
(gb->apu_output.sample_cycles >= clock_rate) || (gb->apu_output.sample_cycles >= clock_rate) ||
(gb->apu.square_sweep_calculate_countdown || gb->apu.channel_1_restart_hold) || (gb->apu.square_sweep_calculate_countdown || gb->apu.channel_1_restart_hold) ||
(gb->model < GB_MODEL_AGB && (gb->apu.wave_channel.bugged_read_countdown || (gb->apu.wave_channel.enable && gb->apu.wave_channel.pulsed)))) { (gb->model <= GB_MODEL_CGB_E && (gb->apu.wave_channel.bugged_read_countdown || (gb->apu.wave_channel.enable && gb->apu.wave_channel.pulsed)))) {
force = true; force = true;
} }
if (!force) { if (!force) {
@ -731,7 +731,7 @@ void GB_apu_run(GB_gameboy_t *gb, bool force)
gb->apu.wave_channel.wave_form_just_read = false; gb->apu.wave_channel.wave_form_just_read = false;
} }
} }
else if (gb->apu.wave_channel.enable && gb->apu.wave_channel.pulsed && gb->model < GB_MODEL_AGB) { else if (gb->apu.wave_channel.enable && gb->apu.wave_channel.pulsed && gb->model <= GB_MODEL_CGB_E) {
uint16_t cycles_left = cycles; uint16_t cycles_left = cycles;
while (unlikely(cycles_left > gb->apu.wave_channel.sample_countdown)) { while (unlikely(cycles_left > gb->apu.wave_channel.sample_countdown)) {
cycles_left -= gb->apu.wave_channel.sample_countdown + 1; cycles_left -= gb->apu.wave_channel.sample_countdown + 1;
@ -849,7 +849,7 @@ uint8_t GB_apu_read(GB_gameboy_t *gb, uint8_t reg)
if (!GB_is_cgb(gb) && !gb->apu.wave_channel.wave_form_just_read) { if (!GB_is_cgb(gb) && !gb->apu.wave_channel.wave_form_just_read) {
return 0xFF; return 0xFF;
} }
if (gb->model == GB_MODEL_AGB) { if (gb->model > GB_MODEL_CGB_E) {
return 0xFF; return 0xFF;
} }
reg = GB_IO_WAV_START + gb->apu.wave_channel.current_sample_index / 2; reg = GB_IO_WAV_START + gb->apu.wave_channel.current_sample_index / 2;
@ -964,7 +964,7 @@ static inline uint16_t effective_channel4_counter(GB_gameboy_t *gb)
effective_counter |= 0x10; effective_counter |= 0x10;
} }
break; break;
case GB_MODEL_AGB: case GB_MODEL_AGB_A:
/* TODO: AGBs are not affected, but AGSes are. They don't seem to follow a simple /* TODO: AGBs are not affected, but AGSes are. They don't seem to follow a simple
pattern like the other revisions. */ pattern like the other revisions. */
/* For the most part, AGS seems to do: /* For the most part, AGS seems to do:
@ -992,7 +992,7 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
} }
if (reg >= GB_IO_WAV_START && reg <= GB_IO_WAV_END && gb->apu.is_active[GB_WAVE]) { if (reg >= GB_IO_WAV_START && reg <= GB_IO_WAV_END && gb->apu.is_active[GB_WAVE]) {
if ((!GB_is_cgb(gb) && !gb->apu.wave_channel.wave_form_just_read) || gb->model == GB_MODEL_AGB) { if ((!GB_is_cgb(gb) && !gb->apu.wave_channel.wave_form_just_read) || gb->model > GB_MODEL_CGB_E) {
return; return;
} }
reg = GB_IO_WAV_START + gb->apu.wave_channel.current_sample_index / 2; reg = GB_IO_WAV_START + gb->apu.wave_channel.current_sample_index / 2;
@ -1226,7 +1226,7 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
gb->apu.wave_channel.pulsed = false; gb->apu.wave_channel.pulsed = false;
if (gb->apu.is_active[GB_WAVE]) { if (gb->apu.is_active[GB_WAVE]) {
// Todo: I assume this happens on pre-CGB models; test this with an audible test // Todo: I assume this happens on pre-CGB models; test this with an audible test
if (gb->apu.wave_channel.sample_countdown == 0 && gb->model < GB_MODEL_AGB) { if (gb->apu.wave_channel.sample_countdown == 0 && gb->model <= GB_MODEL_CGB_E) {
gb->apu.wave_channel.current_sample_byte = gb->io_registers[GB_IO_WAV_START + (gb->pc & 0xF)]; gb->apu.wave_channel.current_sample_byte = gb->io_registers[GB_IO_WAV_START + (gb->pc & 0xF)];
} }
else if (gb->apu.wave_channel.wave_form_just_read && gb->model <= GB_MODEL_CGB_C) { else if (gb->apu.wave_channel.wave_form_just_read && gb->model <= GB_MODEL_CGB_C) {

View File

@ -159,7 +159,7 @@ void GB_display_vblank(GB_gameboy_t *gb)
GB_borrow_sgb_border(gb); GB_borrow_sgb_border(gb);
uint32_t border_colors[16 * 4]; uint32_t border_colors[16 * 4];
if (!gb->has_sgb_border && GB_is_cgb(gb) && gb->model != GB_MODEL_AGB) { if (!gb->has_sgb_border && GB_is_cgb(gb) && gb->model <= GB_MODEL_CGB_E) {
uint16_t colors[] = { uint16_t colors[] = {
0x2095, 0x5129, 0x1EAF, 0x1EBA, 0x4648, 0x2095, 0x5129, 0x1EAF, 0x1EBA, 0x4648,
0x30DA, 0x69AD, 0x2B57, 0x2B5D, 0x632C, 0x30DA, 0x69AD, 0x2B57, 0x2B5D, 0x632C,
@ -277,7 +277,7 @@ uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color, bool for_border)
b = scale_channel_with_curve_sgb(b); b = scale_channel_with_curve_sgb(b);
} }
else { else {
bool agb = gb->model == GB_MODEL_AGB; bool agb = gb->model > GB_MODEL_CGB_E;
r = agb? scale_channel_with_curve_agb(r) : scale_channel_with_curve(r); r = agb? scale_channel_with_curve_agb(r) : scale_channel_with_curve(r);
g = agb? scale_channel_with_curve_agb(g) : scale_channel_with_curve(g); g = agb? scale_channel_with_curve_agb(g) : scale_channel_with_curve(g);
b = agb? scale_channel_with_curve_agb(b) : scale_channel_with_curve(b); b = agb? scale_channel_with_curve_agb(b) : scale_channel_with_curve(b);

View File

@ -121,7 +121,7 @@ static void load_default_border(GB_gameboy_t *gb)
} }
#endif #endif
if (gb->model == GB_MODEL_AGB) { if (gb->model > GB_MODEL_CGB_E) {
#include "graphics/agb_border.inc" #include "graphics/agb_border.inc"
LOAD_BORDER(); LOAD_BORDER();
} }
@ -1378,7 +1378,7 @@ static void reset_ram(GB_gameboy_t *gb)
switch (gb->model) { switch (gb->model) {
case GB_MODEL_MGB: case GB_MODEL_MGB:
case GB_MODEL_CGB_E: case GB_MODEL_CGB_E:
case GB_MODEL_AGB: /* Unverified */ case GB_MODEL_AGB_A: /* Unverified */
for (unsigned i = 0; i < gb->ram_size; i++) { for (unsigned i = 0; i < gb->ram_size; i++) {
gb->ram[i] = GB_random(); gb->ram[i] = GB_random();
} }
@ -1442,7 +1442,7 @@ static void reset_ram(GB_gameboy_t *gb)
case GB_MODEL_CGB_C: case GB_MODEL_CGB_C:
case GB_MODEL_CGB_D: case GB_MODEL_CGB_D:
case GB_MODEL_CGB_E: case GB_MODEL_CGB_E:
case GB_MODEL_AGB: case GB_MODEL_AGB_A:
for (unsigned i = 0; i < sizeof(gb->hram); i++) { for (unsigned i = 0; i < sizeof(gb->hram); i++) {
gb->hram[i] = GB_random(); gb->hram[i] = GB_random();
} }
@ -1475,8 +1475,8 @@ static void reset_ram(GB_gameboy_t *gb)
case GB_MODEL_CGB_C: case GB_MODEL_CGB_C:
case GB_MODEL_CGB_D: case GB_MODEL_CGB_D:
case GB_MODEL_CGB_E: case GB_MODEL_CGB_E:
case GB_MODEL_AGB: case GB_MODEL_AGB_A:
/* Zero'd out by boot ROM anyway, extra OAM no accessible */ /* Zero'd out by boot ROM anyway */
break; break;
case GB_MODEL_DMG_B: case GB_MODEL_DMG_B:
@ -1509,7 +1509,7 @@ static void reset_ram(GB_gameboy_t *gb)
case GB_MODEL_CGB_C: case GB_MODEL_CGB_C:
case GB_MODEL_CGB_D: case GB_MODEL_CGB_D:
case GB_MODEL_CGB_E: case GB_MODEL_CGB_E:
case GB_MODEL_AGB: case GB_MODEL_AGB_A:
/* Initialized by CGB-A and newer, 0s in CGB-0 */ /* Initialized by CGB-A and newer, 0s in CGB-0 */
break; break;
case GB_MODEL_MGB: { case GB_MODEL_MGB: {
@ -1589,7 +1589,7 @@ static void request_boot_rom(GB_gameboy_t *gb)
case GB_MODEL_CGB_E: case GB_MODEL_CGB_E:
type = GB_BOOT_ROM_CGB; type = GB_BOOT_ROM_CGB;
break; break;
case GB_MODEL_AGB: case GB_MODEL_AGB_A:
type = GB_BOOT_ROM_AGB; type = GB_BOOT_ROM_AGB;
break; break;
} }

View File

@ -115,7 +115,10 @@ typedef enum {
GB_MODEL_CGB_C = 0x203, GB_MODEL_CGB_C = 0x203,
GB_MODEL_CGB_D = 0x204, GB_MODEL_CGB_D = 0x204,
GB_MODEL_CGB_E = 0x205, GB_MODEL_CGB_E = 0x205,
GB_MODEL_AGB = 0x206, // GB_MODEL_AGB_0 = 0x206,
GB_MODEL_AGB_A = 0x207,
GB_MODEL_AGB = GB_MODEL_AGB_A,
//GB_MODEL_AGB_B = 0x208
} GB_model_t; } GB_model_t;
enum { enum {

View File

@ -562,7 +562,7 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr)
switch (gb->model) { switch (gb->model) {
case GB_MODEL_CGB_E: case GB_MODEL_CGB_E:
case GB_MODEL_AGB: case GB_MODEL_AGB_A:
return (addr & 0xF0) | ((addr >> 4) & 0xF); return (addr & 0xF0) | ((addr >> 4) & 0xF);
case GB_MODEL_CGB_D: case GB_MODEL_CGB_D:
@ -694,7 +694,7 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr)
if (gb->model != GB_MODEL_CGB_E) { if (gb->model != GB_MODEL_CGB_E) {
ret |= 0x10; ret |= 0x10;
} }
if (((gb->io_registers[GB_IO_RP] & 0xC0) == 0xC0 && gb->effective_ir_input) && gb->model != GB_MODEL_AGB) { if (((gb->io_registers[GB_IO_RP] & 0xC0) == 0xC0 && gb->effective_ir_input) && gb->model <= GB_MODEL_CGB_E) {
ret &= ~2; ret &= ~2;
} }
return ret; return ret;
@ -1240,7 +1240,7 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
gb->extra_oam[addr - 0xfea0] = value; gb->extra_oam[addr - 0xfea0] = value;
break; break;
case GB_MODEL_CGB_E: case GB_MODEL_CGB_E:
case GB_MODEL_AGB: case GB_MODEL_AGB_A:
break; break;
case GB_MODEL_DMG_B: case GB_MODEL_DMG_B:
case GB_MODEL_MGB: case GB_MODEL_MGB:

View File

@ -323,7 +323,7 @@ static bool verify_and_update_state_compatibility(GB_gameboy_t *gb, GB_gameboy_t
case GB_MODEL_CGB_C: return true; case GB_MODEL_CGB_C: return true;
case GB_MODEL_CGB_D: return true; case GB_MODEL_CGB_D: return true;
case GB_MODEL_CGB_E: return true; case GB_MODEL_CGB_E: return true;
case GB_MODEL_AGB: return true; case GB_MODEL_AGB_A: return true;
} }
if ((gb->model & GB_MODEL_FAMILY_MASK) == (save->model & GB_MODEL_FAMILY_MASK)) { if ((gb->model & GB_MODEL_FAMILY_MASK) == (save->model & GB_MODEL_FAMILY_MASK)) {
save->model = gb->model; save->model = gb->model;
@ -576,7 +576,7 @@ static int save_state_internal(GB_gameboy_t *gb, virtual_file_t *file, bool appe
case GB_MODEL_CGB_C: bess_core.full_model = BE32('CCC '); break; case GB_MODEL_CGB_C: bess_core.full_model = BE32('CCC '); break;
case GB_MODEL_CGB_D: bess_core.full_model = BE32('CCD '); break; case GB_MODEL_CGB_D: bess_core.full_model = BE32('CCD '); break;
case GB_MODEL_CGB_E: bess_core.full_model = BE32('CCE '); break; case GB_MODEL_CGB_E: bess_core.full_model = BE32('CCE '); break;
case GB_MODEL_AGB: bess_core.full_model = BE32('CA '); break; // SameBoy doesn't emulate a specific AGB revision yet case GB_MODEL_AGB_A: bess_core.full_model = BE32('CAA '); break;
} }
bess_core.pc = LE16(gb->pc); bess_core.pc = LE16(gb->pc);

View File

@ -113,7 +113,7 @@ void GB_timing_sync(GB_gameboy_t *gb)
static void ir_run(GB_gameboy_t *gb, uint32_t cycles) static void ir_run(GB_gameboy_t *gb, uint32_t cycles)
{ {
if ((gb->model == GB_MODEL_AGB || !gb->cgb_mode) && gb->cartridge_type->mbc_type != GB_HUC1 && gb->cartridge_type->mbc_type != GB_HUC3) return; if ((gb->model > GB_MODEL_CGB_E || !gb->cgb_mode) && gb->cartridge_type->mbc_type != GB_HUC1 && gb->cartridge_type->mbc_type != GB_HUC3) return;
if (gb->infrared_input || gb->cart_ir || (gb->io_registers[GB_IO_RP] & 1)) { if (gb->infrared_input || gb->cart_ir || (gb->io_registers[GB_IO_RP] & 1)) {
gb->ir_sensor += cycles; gb->ir_sensor += cycles;
if (gb->ir_sensor > IR_MAX) { if (gb->ir_sensor > IR_MAX) {

View File

@ -622,7 +622,7 @@ restart:
{ {
[MODEL_DMG] = GB_MODEL_DMG_B, [MODEL_DMG] = GB_MODEL_DMG_B,
[MODEL_CGB] = GB_MODEL_CGB_E, [MODEL_CGB] = GB_MODEL_CGB_E,
[MODEL_AGB] = GB_MODEL_AGB, [MODEL_AGB] = GB_MODEL_AGB_A,
[MODEL_MGB] = GB_MODEL_MGB, [MODEL_MGB] = GB_MODEL_MGB,
[MODEL_SGB] = (GB_model_t []) [MODEL_SGB] = (GB_model_t [])
{ {

View File

@ -61,7 +61,7 @@ static const GB_model_t libretro_to_internal_model[] =
[MODEL_DMG_B] = GB_MODEL_DMG_B, [MODEL_DMG_B] = GB_MODEL_DMG_B,
[MODEL_CGB_C] = GB_MODEL_CGB_C, [MODEL_CGB_C] = GB_MODEL_CGB_C,
[MODEL_CGB_E] = GB_MODEL_CGB_E, [MODEL_CGB_E] = GB_MODEL_CGB_E,
[MODEL_AGB] = GB_MODEL_AGB, [MODEL_AGB] = GB_MODEL_AGB_A,
[MODEL_SGB_PAL] = GB_MODEL_SGB_PAL, [MODEL_SGB_PAL] = GB_MODEL_SGB_PAL,
[MODEL_SGB_NTSC] = GB_MODEL_SGB_NTSC, [MODEL_SGB_NTSC] = GB_MODEL_SGB_NTSC,
[MODEL_SGB2] = GB_MODEL_SGB2 [MODEL_SGB2] = GB_MODEL_SGB2