Kuribo64
Views: 19,850,322 Home | Forums | Uploader | Wiki | Object databases | IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search
03-28-24 09:57 AM
Guest:

0 users reading Nintendo DS Emulator programming in C++ | 1 bot

Main - Misc. ROM hacking - Nintendo DS Emulator programming in C++ Hide post layouts | Thread closed


StarLand
Posted on 03-23-14 07:59 PM Link | #39591
I would like try, programming a NDS Emulator in C++.

[spoiler yopyop Quellcode]
/* Copyright (C) 2006 yopyop yopyop156@ifrance.com yopyop156.ifrance.com

Copyright 2008 CrazyMax
Copyright 2008-2009 DeSmuME team

This file is part of DeSmuME

DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

// TODO: interrupt handler

include "rtc.h"

include "common.h"

include "debug.h"

include "armcpu.h"

include

include

typedef struct { // RTC registers u8 regStatus1; u8 regStatus2; u8 regAdjustment; u8 regFree;

// BUS
u8 _prevSCK;
u8 _prevCS;
u8 _prevSIO;
u8 _SCK;
u8 _CS;
u8 _SIO;
u8 _DD;
u16 _REG;

// command & data
u8 cmd;
u8 cmdStat;
u8 bitsCount;
u8 data[8];
} _RTC;

_RTC rtc;

u8 cmdBitsSize[8] = {8, 8, 56, 24, 0, 24, 8, 8};

define toBCD(x) ((x / 10) << 4) | (x % 10);

static void rtcRecv() { //INFO("RTC Read command 0x%02X\n", rtc.cmd); memset(rtc.data, 0, sizeof(rtc.data)); switch (rtc.cmd) { case 0: // status register 1 //INFO("RTC: read regstatus1 (0x%02X)\n", rtc.regStatus1); rtc.data[0] = rtc.regStatus1; rtc.regStatus1 &= 0x7F; break; case 1: // status register 2 //INFO("RTC: read regstatus2 (0x%02X)\n", rtc.regStatus1); rtc.data[0] = rtc.regStatus2; break; case 2: // date & time { //INFO("RTC: read date & time\n"); time_t tm; time(&tm); struct tm *tm_local= localtime(&tm); tm_local->tm_year %= 100; tm_local->tm_mon++; rtc.data[0] = toBCD(tm_local->tm_year); rtc.data[1] = toBCD(tm_local->tm_mon); rtc.data[2] = toBCD(tm_local->tm_mday); rtc.data[3] = (tm_local->tm_wday + 6) & 7; if (!(rtc.regStatus1 & 0x02)) tm_local->tm_hour %= 12; rtc.data[4] = ((tm_local->tm_hour < 12) ? 0x00 : 0x40) | toBCD(tm_local->tm_hour); rtc.data[5] = toBCD(tm_local->tm_min); rtc.data[6] = toBCD(tm_local->tm_sec); break; } case 3: // time { //INFO("RTC: read time\n"); time_t tm; time(&tm); struct tm *tm_local= localtime(&tm); if (!(rtc.regStatus1 & 0x02)) tm_local->tm_hour %= 12; rtc.data[0] = ((tm_local->tm_hour < 12) ? 0x00 : 0x40) | toBCD(tm_local->tm_hour); rtc.data[1] = toBCD(tm_local->tm_min); rtc.data[2] = toBCD(tm_local->tm_sec); break; }

Arisotura
Posted on 03-23-14 08:02 PM Link | #39593
What's the point of this thread? And why did you post random code?

____________________
NSMBHD - Kafuka - Jul
melonDS the most fruity DS emulator there is

zafkflzdasd


Main - Misc. ROM hacking - Nintendo DS Emulator programming in C++ Hide post layouts | Thread closed

Page rendered in 0.037 seconds. (2048KB of memory used)
MySQL - queries: 26, rows: 198/198, time: 0.015 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.