FS#12113: Optimize IRAM configuration for Atari SAP format. Performance gains range...
[kugel-rb.git] / apps / codecs / libasap / asap_internal.h
blobdef444bc2f6e219bbc191e24e0aa98b5b0bc6104
1 /*
2 * asap_internal.h - private interface of ASAP
4 * Copyright (C) 2005-2010 Piotr Fusik
6 * This file is part of ASAP (Another Slight Atari Player),
7 * see http://asap.sourceforge.net
9 * ASAP is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; either version 2 of the License,
12 * or (at your option) any later version.
14 * ASAP is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty
16 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 * See the GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with ASAP; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #ifndef _ASAP_INTERNAL_H_
25 #define _ASAP_INTERNAL_H_
27 #include "anylang.h"
29 #ifndef C
31 #define ASAP_SONGS_MAX 32
32 #define ASAP_SAMPLE_RATE 44100
34 #endif
36 #ifdef JAVA
38 #define ASAP_FORMAT_U8 8
39 #define ASAP_FORMAT_S16_LE 16
40 #define ASAP_FORMAT_S16_BE -16
41 #define ASAP_SampleFormat int
43 #elif defined(CSHARP) || defined(JAVASCRIPT)
45 #define ASAP_FORMAT_U8 ASAP_SampleFormat.U8
46 #define ASAP_FORMAT_S16_LE ASAP_SampleFormat.S16LE
47 #define ASAP_FORMAT_S16_BE ASAP_SampleFormat.S16BE
49 #elif defined(ACTIONSCRIPT)
51 #define ASAP_SampleFormat int
53 #else /* C */
55 #include "asap.h"
57 int ASAP_GetByte(ASAP_State *ast, int addr);
58 void ASAP_PutByte(ASAP_State *ast, int addr, int data);
60 void Cpu_RunScanlines(ASAP_State *ast, int scanlines);
62 void PokeySound_Initialize(ASAP_State *ast);
63 void PokeySound_StartFrame(ASAP_State *ast);
64 void PokeySound_PutByte(ASAP_State *ast, int addr, int data);
65 int PokeySound_GetRandom(ASAP_State *ast, int addr, int cycle);
66 void PokeySound_EndFrame(ASAP_State *ast, int cycle_limit);
67 int PokeySound_Generate(ASAP_State *ast, byte buffer[], int buffer_offset, int blocks, ASAP_SampleFormat format);
68 abool PokeySound_IsSilent(const PokeyState *pst);
69 void PokeySound_Mute(const ASAP_State *ast, PokeyState *pst, int mask);
71 #ifdef ASAPSCAN
72 abool call_6502_player(ASAP_State *ast);
73 extern int cpu_trace;
74 void trace_cpu(const ASAP_State *ast, int pc, int a, int x, int y, int s, int nz, int vdi, int c);
75 #endif
77 #endif /* C */
79 #define V_FLAG 0x40
80 #define D_FLAG 0x08
81 #define I_FLAG 0x04
82 #define Z_FLAG 0x02
84 #define NEVER 0x800000
86 #define DELTA_SHIFT_POKEY 20
87 #define DELTA_SHIFT_GTIA 20
88 #define DELTA_SHIFT_COVOX 17
90 /* 6502 player types */
91 #define ASAP_TYPE_SAP_B 1
92 #define ASAP_TYPE_SAP_C 2
93 #define ASAP_TYPE_SAP_D 3
94 #define ASAP_TYPE_SAP_S 4
95 #define ASAP_TYPE_CMC 5
96 #define ASAP_TYPE_CM3 6
97 #define ASAP_TYPE_CMR 7
98 #define ASAP_TYPE_CMS 8
99 #define ASAP_TYPE_DLT 9
100 #define ASAP_TYPE_MPT 10
101 #define ASAP_TYPE_RMT 11
102 #define ASAP_TYPE_TMC 12
103 #define ASAP_TYPE_TM2 13
105 #define dGetByte(addr) UBYTE(ast _ memory[addr])
106 #define dPutByte(addr, data) ast _ memory[addr] = CAST(byte) (data)
107 #define dGetWord(addr) (dGetByte(addr) + (dGetByte((addr) + 1) << 8))
108 #define GetByte(addr) (((addr) & 0xf900) == 0xd000 ? ASAP_GetByte(ast, addr) : dGetByte(addr))
109 #define PutByte(addr, data) do { if (((addr) & 0xf900) == 0xd000) ASAP_PutByte(ast, addr, data); else dPutByte(addr, data); } while (FALSE)
110 #define RMW_GetByte(dest, addr) do { if (((addr) >> 8) == 0xd2) { dest = ASAP_GetByte(ast, addr); ast _ cycle--; ASAP_PutByte(ast, addr, dest); ast _ cycle++; } else dest = dGetByte(addr); } while (FALSE)
112 #define ASAP_MAIN_CLOCK(ast) ((ast) _ module_info->ntsc ? 1789772 : 1773447)
113 #define CYCLE_TO_SAMPLE(cycle) TO_INT(((cycle) * ASAP_SAMPLE_RATE + ast _ sample_offset) / ASAP_MAIN_CLOCK(ast))
115 #endif /* _ASAP_INTERNAL_H_ */