Ben Evans University Second Year Project. Game Called Defender.
Hello, soldier, you have been specially selected as the defender of planet earth.
Your mission, if you choose to accept it. Fly around the planet and pulverise invading alien ships for as long as you can. Stop the aliens abducting the innocent people on the ground. Be warned if an alien ship manages to abduct a person and take them to top of the screen, they will no longer move randomly and will begin to hunt you down. This sounds like a challenge you were trained for.
But don’t worry soldier you’re not going into battle empty-handed. Your ship is equipped with a state of the art laser beam that has unlimited ammo and four smart bombs that will destroy anything on the screen. The ship also has three lives so use them wisely.
As time goes on more alien ships will arrive on planet earth increasing the difficulty of your mission. And remember the landscape bellow loops around so if you continually fly in the same direction you go to your original position. Good luck soldier.
SDFileSystem/FATFileSystem/ChaN/diskio.cpp@87:832ca78426b5, 2020-05-27 (annotated)
- Committer:
- evanso
- Date:
- Wed May 27 02:06:05 2020 +0000
- Revision:
- 87:832ca78426b5
- Parent:
- 48:e308067cfea5
Final Submission. I have read and agreed with Statement of Academic Integrity.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
evanso | 48:e308067cfea5 | 1 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 2 | /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */ |
evanso | 48:e308067cfea5 | 3 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 4 | /* If a working storage control module is available, it should be */ |
evanso | 48:e308067cfea5 | 5 | /* attached to the FatFs via a glue function rather than modifying it. */ |
evanso | 48:e308067cfea5 | 6 | /* This is an example of glue functions to attach various exsisting */ |
evanso | 48:e308067cfea5 | 7 | /* storage control modules to the FatFs module with a defined API. */ |
evanso | 48:e308067cfea5 | 8 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 9 | |
evanso | 48:e308067cfea5 | 10 | #include "diskio.h" |
evanso | 48:e308067cfea5 | 11 | #include "mbed_debug.h" |
evanso | 48:e308067cfea5 | 12 | #include "FATFileSystem.h" |
evanso | 48:e308067cfea5 | 13 | |
evanso | 48:e308067cfea5 | 14 | using namespace mbed; |
evanso | 48:e308067cfea5 | 15 | |
evanso | 48:e308067cfea5 | 16 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 17 | /* Get Drive Status */ |
evanso | 48:e308067cfea5 | 18 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 19 | |
evanso | 48:e308067cfea5 | 20 | DSTATUS disk_status ( |
evanso | 48:e308067cfea5 | 21 | BYTE pdrv /* Physical drive nmuber to identify the drive */ |
evanso | 48:e308067cfea5 | 22 | ) |
evanso | 48:e308067cfea5 | 23 | { |
evanso | 48:e308067cfea5 | 24 | debug_if(FFS_DBG, "disk_status on pdrv [%d]\n", pdrv); |
evanso | 48:e308067cfea5 | 25 | return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_status(); |
evanso | 48:e308067cfea5 | 26 | } |
evanso | 48:e308067cfea5 | 27 | |
evanso | 48:e308067cfea5 | 28 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 29 | /* Inidialize a Drive */ |
evanso | 48:e308067cfea5 | 30 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 31 | |
evanso | 48:e308067cfea5 | 32 | DSTATUS disk_initialize ( |
evanso | 48:e308067cfea5 | 33 | BYTE pdrv /* Physical drive nmuber to identify the drive */ |
evanso | 48:e308067cfea5 | 34 | ) |
evanso | 48:e308067cfea5 | 35 | { |
evanso | 48:e308067cfea5 | 36 | debug_if(FFS_DBG, "disk_initialize on pdrv [%d]\n", pdrv); |
evanso | 48:e308067cfea5 | 37 | return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_initialize(); |
evanso | 48:e308067cfea5 | 38 | } |
evanso | 48:e308067cfea5 | 39 | |
evanso | 48:e308067cfea5 | 40 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 41 | /* Read Sector(s) */ |
evanso | 48:e308067cfea5 | 42 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 43 | |
evanso | 48:e308067cfea5 | 44 | DRESULT disk_read ( |
evanso | 48:e308067cfea5 | 45 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ |
evanso | 48:e308067cfea5 | 46 | BYTE* buff, /* Data buffer to store read data */ |
evanso | 48:e308067cfea5 | 47 | DWORD sector, /* Sector address in LBA */ |
evanso | 48:e308067cfea5 | 48 | UINT count /* Number of sectors to read */ |
evanso | 48:e308067cfea5 | 49 | ) |
evanso | 48:e308067cfea5 | 50 | { |
evanso | 48:e308067cfea5 | 51 | debug_if(FFS_DBG, "disk_read(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv); |
evanso | 48:e308067cfea5 | 52 | if (FATFileSystem::_ffs[pdrv]->disk_read((uint8_t*)buff, sector, count)) |
evanso | 48:e308067cfea5 | 53 | return RES_PARERR; |
evanso | 48:e308067cfea5 | 54 | else |
evanso | 48:e308067cfea5 | 55 | return RES_OK; |
evanso | 48:e308067cfea5 | 56 | } |
evanso | 48:e308067cfea5 | 57 | |
evanso | 48:e308067cfea5 | 58 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 59 | /* Write Sector(s) */ |
evanso | 48:e308067cfea5 | 60 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 61 | |
evanso | 48:e308067cfea5 | 62 | #if _USE_WRITE |
evanso | 48:e308067cfea5 | 63 | DRESULT disk_write ( |
evanso | 48:e308067cfea5 | 64 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ |
evanso | 48:e308067cfea5 | 65 | const BYTE* buff, /* Data to be written */ |
evanso | 48:e308067cfea5 | 66 | DWORD sector, /* Sector address in LBA */ |
evanso | 48:e308067cfea5 | 67 | UINT count /* Number of sectors to write */ |
evanso | 48:e308067cfea5 | 68 | ) |
evanso | 48:e308067cfea5 | 69 | { |
evanso | 48:e308067cfea5 | 70 | debug_if(FFS_DBG, "disk_write(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv); |
evanso | 48:e308067cfea5 | 71 | if (FATFileSystem::_ffs[pdrv]->disk_write((uint8_t*)buff, sector, count)) |
evanso | 48:e308067cfea5 | 72 | return RES_PARERR; |
evanso | 48:e308067cfea5 | 73 | else |
evanso | 48:e308067cfea5 | 74 | return RES_OK; |
evanso | 48:e308067cfea5 | 75 | } |
evanso | 48:e308067cfea5 | 76 | #endif |
evanso | 48:e308067cfea5 | 77 | |
evanso | 48:e308067cfea5 | 78 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 79 | /* Miscellaneous Functions */ |
evanso | 48:e308067cfea5 | 80 | /*-----------------------------------------------------------------------*/ |
evanso | 48:e308067cfea5 | 81 | |
evanso | 48:e308067cfea5 | 82 | #if _USE_IOCTL |
evanso | 48:e308067cfea5 | 83 | DRESULT disk_ioctl ( |
evanso | 48:e308067cfea5 | 84 | BYTE pdrv, /* Physical drive nmuber (0..) */ |
evanso | 48:e308067cfea5 | 85 | BYTE cmd, /* Control code */ |
evanso | 48:e308067cfea5 | 86 | void* buff /* Buffer to send/receive control data */ |
evanso | 48:e308067cfea5 | 87 | ) |
evanso | 48:e308067cfea5 | 88 | { |
evanso | 48:e308067cfea5 | 89 | debug_if(FFS_DBG, "disk_ioctl(%d)\n", cmd); |
evanso | 48:e308067cfea5 | 90 | switch(cmd) { |
evanso | 48:e308067cfea5 | 91 | case CTRL_SYNC: |
evanso | 48:e308067cfea5 | 92 | if(FATFileSystem::_ffs[pdrv] == NULL) { |
evanso | 48:e308067cfea5 | 93 | return RES_NOTRDY; |
evanso | 48:e308067cfea5 | 94 | } else if(FATFileSystem::_ffs[pdrv]->disk_sync()) { |
evanso | 48:e308067cfea5 | 95 | return RES_ERROR; |
evanso | 48:e308067cfea5 | 96 | } |
evanso | 48:e308067cfea5 | 97 | return RES_OK; |
evanso | 48:e308067cfea5 | 98 | case GET_SECTOR_COUNT: |
evanso | 48:e308067cfea5 | 99 | if(FATFileSystem::_ffs[pdrv] == NULL) { |
evanso | 48:e308067cfea5 | 100 | return RES_NOTRDY; |
evanso | 48:e308067cfea5 | 101 | } else { |
evanso | 48:e308067cfea5 | 102 | DWORD res = FATFileSystem::_ffs[pdrv]->disk_sectors(); |
evanso | 48:e308067cfea5 | 103 | if(res > 0) { |
evanso | 48:e308067cfea5 | 104 | *((DWORD*)buff) = res; // minimum allowed |
evanso | 48:e308067cfea5 | 105 | return RES_OK; |
evanso | 48:e308067cfea5 | 106 | } else { |
evanso | 48:e308067cfea5 | 107 | return RES_ERROR; |
evanso | 48:e308067cfea5 | 108 | } |
evanso | 48:e308067cfea5 | 109 | } |
evanso | 48:e308067cfea5 | 110 | case GET_BLOCK_SIZE: |
evanso | 48:e308067cfea5 | 111 | *((DWORD*)buff) = 1; // default when not known |
evanso | 48:e308067cfea5 | 112 | return RES_OK; |
evanso | 48:e308067cfea5 | 113 | |
evanso | 48:e308067cfea5 | 114 | } |
evanso | 48:e308067cfea5 | 115 | return RES_PARERR; |
evanso | 48:e308067cfea5 | 116 | } |
evanso | 48:e308067cfea5 | 117 | #endif |